/* 迅利量化套利系统 - 网页版样式（对齐原 WPF 蓝白配色） */
:root {
  --primary: #4A90E2;
  --primary-dark: #357ABD;
  --bg: #FAFAFA;
  --border: #E0E0E0;
  --text: #212121;
  --muted: #616161;
  --success: #28A745;
  --danger: #DC3545;
  --header: #E3F2FD;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.empty-layout, .trade-layout, #app {
  min-height: 100vh;
}

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f1fb 0%, #f7f9fc 50%, #dceaf8 100%);
}
.login-card {
  width: 400px;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  overflow: hidden;
}
.login-header {
  height: 120px;
  background: linear-gradient(135deg, #4A90E2, #357ABD);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.login-logo { width: 64px; height: 64px; object-fit: contain; margin-bottom: 4px; }
.login-title { font-size: 14px; opacity: .95; }
.login-sub { font-size: 12px; opacity: .8; margin-top: 2px; }
.login-body { padding: 28px 36px 32px; }
.field-label { display: block; font-weight: 600; margin: 0 0 8px 4px; }
.field-box {
  background: #F8F9FA;
  border: 1px solid #E9ECEF;
  border-radius: 8px;
  height: 44px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}
.field-box input, input.full {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
}
input.full {
  background: #F8F9FA;
  border: 1px solid #E9ECEF;
  border-radius: 8px;
  height: 40px;
  padding: 0 12px;
}
.login-links { text-align: right; margin-bottom: 18px; }
.login-links a { color: var(--primary); font-size: 12px; text-decoration: none; }
.login-btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 24px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(90deg, #4A90E2, #357ABD);
  box-shadow: 0 4px 12px rgba(74,144,226,.35);
}
.login-btn:disabled { opacity: .6; cursor: wait; }
.login-error { color: var(--danger); text-align: center; margin-top: 12px; font-size: 12px; }
.login-footer-link { text-align: center; margin-top: 16px; color: var(--muted); font-size: 12px; }
.local-hint {
  background: #F0F7FF;
  border: 1px solid #BBDEFB;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #357ABD;
  line-height: 1.5;
  margin-bottom: 18px;
}
.toggle-pair { display: flex; gap: 6px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acc-actions { grid-column: 1 / -1; display: flex; gap: 4px; margin-top: 2px; }

/* ===== Trade desk (对齐 WPF MainWindow) ===== */
.trade-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: #FAFAFA; }
.top-bar {
  height: 30px;
  background: #4A90E2;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  font-size: 12px;
  flex-shrink: 0;
  cursor: context-menu;
  user-select: none;
}
.top-bar .sep { opacity: .7; font-weight: 700; margin: 0 2px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.auto-toggle {
  border: none; border-radius: 6px; padding: 2px 8px; font-size: 10px; font-weight: 700; color: #fff; cursor: pointer;
}
.auto-toggle.on { background: #4CAF50; }
.auto-toggle.off { background: #9E9E9E; }
.link-btn { background: none; border: none; color: #fff; text-decoration: underline; cursor: pointer; font-size: 11px; }

.ctx-backdrop { position: fixed; inset: 0; z-index: 1800; }
.ctx-menu {
  position: fixed; z-index: 1801; background: #fff; border: 1px solid #ccc; border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); min-width: 160px; padding: 4px 0;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  padding: 7px 14px; font-size: 12px; cursor: pointer;
}
.ctx-menu button:hover { background: #E3F2FD; }
.ctx-menu button.danger { color: #DC3545; }
.ctx-sep { height: 1px; background: #E0E0E0; margin: 4px 8px; }
.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: middle;
}
.dot.green { background: limegreen; }
.dot.red { background: red; }
.dot.blue { background: dodgerblue; }
.dot.dgreen { background: darkgreen; }
.dot.orange { background: orange; }
.dot.purple { background: purple; }
.dot.brown { background: brown; }
.dot.teal { background: teal; }
.dot.orangered { background: orangered; }

.dlg-xl { width: 720px; }
.dlg-xxl { width: 960px; max-width: 96vw; }
.dlg-config { width: 640px; max-width: 96vw; }
.dlg-scroll { max-height: 60vh; overflow: auto; padding-right: 6px; }
.dlg-section { color: #1976D2; margin: 12px 0 8px; }
.dlg-legal { font-size: 12px; line-height: 1.7; padding-left: 18px; }
.dlg-warn {
  background: #FFF3CD; border: 1px solid #FFC107; border-radius: 5px; padding: 12px; margin-top: 12px;
}
.dlg-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px;
}
.dlg-table-wrap { max-height: 55vh; overflow: auto; border: 1px solid #E0E0E0; }
.dlg-table-wrap .left { text-align: left; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-hint { color: #616161; text-align: center; padding: 24px; }

.cfg-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cfg-col { display: flex; flex-direction: column; gap: 6px; }
.cfg-row {
  display: grid; grid-template-columns: 88px 1fr; border: 1px solid #E0E0E0; border-radius: 4px; overflow: hidden; align-items: stretch;
}
.cfg-label {
  background: #E3F2FD; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border-right: 1px solid #E0E0E0; padding: 4px;
}
.cfg-row input, .cfg-row select {
  border: none; height: 28px; padding: 0 8px; width: 100%; font-size: 12px; background: #fff;
}
.cfg-dual { display: grid; grid-template-columns: 1fr 1fr; }
.cfg-dual input, .cfg-dual select { border-right: 1px solid #eee; }
.cfg-switch { display: flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 12px; }
.notify-checks { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 6px 8px; font-size: 12px; }
.full { width: 100%; }

@media (max-width: 900px) {
  .cfg-two-col { grid-template-columns: 1fr; }
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 4px;
  gap: 0;
  --main-left: 66.67%;
  --left-top: 50%;
  --pos-top: 50%;
  --price-w: 200px;
}
.left-pane {
  width: var(--main-left);
  min-width: 400px;
  max-width: calc(100% - 285px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-right: 2px;
  box-sizing: border-box;
}
.right-pane {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-left: 2px;
  box-sizing: border-box;
}
/* 对齐 WPF：账户 Auto+顶对齐，中间 * 空隙，报价固定宽 */
.left-top {
  height: var(--left-top);
  min-height: 200px;
  max-height: calc(100% - 155px);
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  padding: 4px 4px 8px 4px;
  box-sizing: border-box;
  background: #FAFAFA;
}
.left-bottom {
  flex: 1;
  min-height: 150px;
  overflow: auto;
  margin-top: 2px;
}
/* 主/对冲：略收窄，与报价区间距约 108px（原 36×3） */
.accounts-pair {
  flex: 1 1 auto;
  min-width: 480px;
  width: auto;
  max-width: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-self: flex-start;
  min-height: 160px;
  max-height: min(360px, calc(100% - 8px));
  margin: 0;
}
.accounts-gap {
  flex: 0 0 108px;
  width: 108px;
  min-width: 108px;
  max-width: 108px;
  align-self: stretch;
}
.split-v {
  width: 5px;
  flex: 0 0 5px;
  cursor: col-resize;
  background: #fff;
  border-left: 1px solid #E0E0E0;
  border-right: 1px solid #E0E0E0;
  align-self: stretch;
  z-index: 3;
  touch-action: none;
  user-select: none;
}
.split-h {
  height: 5px;
  flex: 0 0 5px;
  cursor: row-resize;
  background: #fff;
  border-top: 1px solid #CCC;
  border-bottom: 1px solid #CCC;
  margin: 2px 0;
  z-index: 3;
  touch-action: none;
  user-select: none;
}
.split-v:hover, .split-h:hover,
.split-v:active, .split-h:active { background: #BBDEFB; }
body.splitting { cursor: col-resize; user-select: none; }
body.splitting .split-h { cursor: row-resize; }

.account-side {
  width: auto;
  min-width: 0;
  max-width: none;
  background: #fff;
  border: 2px solid #ccc;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  max-height: 360px;
  overflow: hidden;
  box-sizing: border-box;
}
.account-side.side-ok { border-color: #2EB450; }
.account-side.side-wait { border-color: #FFA500; }
.account-side.side-off { border-color: #DC3C3C; }

.side-summary {
  position: relative; padding: 6px 8px 4px; border-bottom: 1px solid #E0E0E0; background: #FAFAFA; font-size: 11px; flex-shrink: 0;
}
.sum-title { font-weight: 700; font-size: 12px; margin-bottom: 2px; color: #212121; }
.sum-line { line-height: 1.35; color: #212121; }
.sum-line.muted { color: #616161; }
.sum-line.bold { font-weight: 700; }
.add-plus {
  position: absolute; right: 6px; top: 4px; width: 22px; height: 22px; border-radius: 4px;
  border: 1px solid #4A90E2; background: #E3F2FD; color: #4A90E2; font-weight: 700; cursor: pointer; line-height: 1;
}
.add-plus:hover { background: #4A90E2; color: #fff; }

.acc-list {
  flex: 1; overflow: auto; padding: 4px; max-height: 160px; background: #fff;
}
.acc-item {
  display: grid; grid-template-columns: 22px 28px 1fr auto auto 18px; gap: 4px; align-items: center;
  border: none; border-left: 3px solid #C8C8C8; border-radius: 0; padding: 4px; margin-bottom: 2px; font-size: 11px; cursor: default;
  background: #F8FAFC;
}
.acc-item:nth-child(even) { background: #fff; }
.acc-idx { color: #556B8D; font-size: 11px; font-weight: 700; }
.acc-item.row-ok { border-left-color: #2EB450; }
.acc-item.row-wait { border-left-color: #FFA500; }
.acc-item.row-off { border-left-color: #DC3C3C; }
.badge {
  width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.badge-ok { background: #2E7D32; }
.badge-near { background: #F9A825; }
.badge-warn { background: #C62828; }
.badge-gray { background: #6B7C93; }
.acc-id { font-weight: 600; color: #212121; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-id.risk { color: #999; text-decoration: line-through; }
.acc-bal { color: #333; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.acc-x {
  width: 18px; height: 18px; border: none; border-radius: 9px; background: transparent;
  color: #DC3545; font-weight: 700; cursor: pointer; line-height: 1; padding: 0;
}
.acc-x:hover { background: #FFEBEE; color: #C0392B; }

.price-col {
  width: var(--price-w);
  min-width: 140px;
  max-width: 280px;
  flex: 0 0 auto;
  margin-left: 5px;
  align-self: stretch;
  background: #fff; border: 1px solid #E0E0E0; border-radius: 4px;
  display: flex; flex-direction: column; overflow: hidden;
}
.price-table { flex: 1; min-height: 80px; }
.price-table th { height: 25px; padding: 2px; font-size: 11px; }
.price-table td { height: 22px; padding: 1px 3px; font-size: 11px; }
.cycle-order {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  padding: 4px 6px; background: #F5F5F5; border-top: 1px solid #E0E0E0; flex-shrink: 0;
}
.cycle-order .batch-btn {
  padding: 4px 10px; height: 24px; font-size: 11px; font-weight: 700;
  border-radius: 3px; line-height: 1; white-space: nowrap;
}
.qty-input {
  width: 44px; height: 24px; text-align: center;
  border: 1px solid #E0E0E0; border-radius: 3px; font-size: 11px; margin: 0 2px;
}

.trade-table-wrap {
  flex: 1; background: #fff; border: 1px solid #E0E0E0; border-radius: 4px; overflow: auto; min-height: 0;
}
.trade-table {
  table-layout: fixed;
  width: 100%;
}
.trade-table th { height: 40px; padding: 4px 3px; font-size: 11px; }
.trade-table td { height: 35px; max-height: 35px; padding: 0 3px; vertical-align: middle; box-sizing: border-box; }
.trade-table td.ops { padding: 0 2px !important; line-height: 0; }

/* 交易表「盈亏:x.xx」表头列：固定 80px（对齐 WPF），金额正负变化不再撑开列宽 */
.trade-table .col-pnl {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  padding: 0 2px !important;
  overflow: hidden;
  box-sizing: border-box;
  text-align: center !important;
}
.trade-table .col-pnl .pnl-head {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.trade-table td.col-pnl {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: center !important;
}

.pos-panel {
  background: #fff; border: 1px solid #E0E0E0; border-radius: 4px;
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
  margin: 0 2px;
}
.pos-panel.pos-top {
  height: var(--pos-top);
  min-height: 80px;
  max-height: calc(100% - 85px);
}
.pos-panel.pos-bottom {
  flex: 1;
  min-height: 80px;
}
.pos-body { flex: 1; overflow: auto; min-height: 0; }
.pos-header {
  height: 25px; background: #E3F2FD; border-bottom: 1px solid #E0E0E0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px; font-weight: 700; font-size: 12px;
}
.pos-stat { font-weight: 500; color: #616161; font-size: 9px; }
.pos-stat b { color: #4A90E2; margin-right: 6px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.data-table th {
  background: #E3F2FD; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid #E0E0E0; padding: 5px 3px; text-align: center; font-weight: 700; color: #212121;
}
.data-table td { border-bottom: 1px solid #D8D8D8; padding: 3px; text-align: center; }
.data-table tbody tr:nth-child(even) { background: #F8F9FA; }
.data-table tbody tr:hover { background: #F5F5F5; }

.ops { white-space: nowrap; width: 195px; min-width: 195px; max-width: 195px; }
.ops-head { min-width: 195px; width: 195px; font-size: 11px; }

/* 持仓表盈亏列 */
.pos-body .col-pnl {
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right !important;
  box-sizing: border-box;
}
.acc-pnl {
  min-width: 64px;
  width: 64px;
  display: inline-block;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}

.btn-blue, .btn-red, .btn-gray, .btn-green, .btn-flat, .btn-nodata {
  border: none; border-radius: 3px; color: #fff; padding: 4px 8px; cursor: pointer; font-size: 10px; font-weight: 700;
  vertical-align: middle; box-sizing: border-box;
}
.btn-blue { background: #4A90E2 !important; color: #fff !important; }
.btn-red { background: #DC3545 !important; color: #fff !important; }
.btn-green { background: #28A745 !important; color: #fff !important; }
.btn-gray { background: #6c757d !important; color: #fff !important; }
/* 平仓：天蓝底 + 深色字（勿用 Bootstrap .btn-close） */
.btn-flat {
  background: #87CEEB !important;
  color: #222222 !important;
  background-image: none !important;
  opacity: 1 !important;
  box-shadow: none !important;
}
.btn-nodata { background: #F0F0F0 !important; color: #666666 !important; border: 1px solid #ccc; cursor: default; }
.ops .sm {
  height: 24px; min-width: 90px; max-height: 24px;
  padding: 0 6px; margin: 0 1px;
  font-size: 10px; line-height: 22px;
  border: 0.5px solid #9E9E9E;
}
.ops .wide {
  height: 24px; max-height: 24px; min-width: 0; width: calc(100% - 4px); max-width: 188px;
  padding: 0 8px; margin: 0 2px;
  font-size: 10px; line-height: 22px;
  border: 0.5px solid #9E9E9E; display: inline-block;
}

.toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(33,33,33,.88); color: #fff; padding: 14px 22px; border-radius: 8px; z-index: 2000; cursor: pointer;
}

/* 避免与 Bootstrap .modal / .modal-backdrop 冲突（Bootstrap 默认 display:none） */
.dlg-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 2500;
}
.dlg {
  background: #fff; border-radius: 10px; padding: 18px 20px; width: 420px; max-width: 92vw; max-height: 85vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); display: block !important;
}
.dlg-lg { width: 640px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dlg-head h3 { margin: 0; font-size: 16px; }
.icon-x { border: none; background: transparent; font-size: 22px; cursor: pointer; line-height: 1; }
.form-grid {
  display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center;
}
.form-grid input[type="number"], .form-grid input[type="text"], .form-grid input[type="password"], .form-grid input:not([type]), .form-grid select {
  height: 32px; border: 1px solid #E0E0E0; border-radius: 4px; padding: 0 8px;
}
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.loading-wrap { padding: 40px; text-align: center; color: #616161; }

.menu-bar {
  display: flex; gap: 6px; padding: 6px 8px; background: #fff; border-bottom: 1px solid #E0E0E0; flex-shrink: 0; flex-wrap: wrap;
}
.menu-bar button {
  border: 1px solid #E0E0E0; background: #fff; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}
.menu-bar button:hover { background: #F5F5F5; }
.menu-bar button.danger { color: #DC3545; border-color: #f5c2c7; margin-left: auto; }

@media (max-width: 1100px) {
  .workspace { flex-direction: column; overflow: auto; }
  .left-pane { width: 100% !important; max-width: none; min-width: 0; min-height: 520px; }
  .right-pane { min-width: 0; min-height: 360px; }
  .main-split, .left-top > .split-v, .accounts-gap { display: none; }
  .left-top { flex-direction: column; height: auto !important; max-height: none; min-height: 280px; padding-bottom: 10px; }
  .accounts-pair {
    width: 100%; max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .account-side { width: auto; max-width: none; }
  .price-col { width: 100% !important; max-width: none; min-height: 140px; margin-left: 0; }
}

/* ===== WPF 子窗口布局对齐 ===== */
.wpf-win {
  background: #f5f5f5;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
  max-width: 96vw;
  max-height: 90vh;
  overflow: hidden;
}
.wpf-win-title {
  height: 36px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: #212121;
  flex-shrink: 0;
}
.wpf-win-body { background: #fff; margin: 8px; flex: 1; min-height: 0; overflow: auto; }
.wpf-win-body.blue-frame { border: 2px solid #4A90E2; border-radius: 8px; padding: 12px; margin: 10px; }
.wpf-win-body.gold-frame { border: 2px solid #FFD700; border-radius: 6px; padding: 16px; margin: 10px; }

.wpf-win-history { width: 1100px; height: 600px; }
.wpf-win-log { width: 1200px; height: 650px; }
.wpf-win-paired { width: 1188px; height: 640px; }
.wpf-win-monitor { width: 1000px; height: 700px; }
.wpf-win-config { width: 580px; background: #FAFAFA; }
.wpf-win-ding { width: 600px; background: #F0F0F0; }
.wpf-win-account { width: 380px; background: #FAFAFA; }
.wpf-win-row { width: 320px; background: #FAFAFA; }
.wpf-win-disclaimer { width: 800px; height: 600px; background: #fff; }

.hist-toolbar {
  height: 50px; background: #fff; border-bottom: 1px solid #e0e0e0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px; flex-shrink: 0; gap: 12px;
}
.hist-toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hist-date { height: 30px; width: 140px; border: 1px solid #ddd; border-radius: 4px; padding: 0 6px; }
.hist-dash { color: #666; }
.hist-stats {
  background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 4px; padding: 6px 14px; font-size: 12px; color: #666; white-space: nowrap;
}
.hist-stats b { color: #007ACC; margin-right: 12px; }
.hist-stats .ml { margin-left: 4px; }
.hist-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 16px 20px; position: relative; background: #f5f5f5; }
.hist-loading {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%);
  background: rgba(224,255,255,.95); border: 2px solid #007ACC; border-radius: 8px;
  padding: 20px 30px; color: #007ACC; font-weight: 700; z-index: 2;
}

.wpf-grid-wrap {
  flex: 1; min-height: 0; overflow: auto; background: #fff; border: 1px solid #e0e0e0;
}
.wpf-grid { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.wpf-grid th {
  background: #f1f3f4; color: #333; font-weight: 600; height: 35px;
  border-bottom: 1px solid #e0e0e0; border-right: 1px solid #e0e0e0;
  text-align: center; position: sticky; top: 0; z-index: 1;
}
.wpf-grid td {
  text-align: center; height: 32px; padding: 4px 6px;
  border-bottom: 1px solid #eee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wpf-grid tbody tr:nth-child(even) { background: #f8f9fa; }
.wpf-grid tbody tr:hover { background: #eef5ff; }
.wpf-grid .left { text-align: left; }
.wpf-grid-lines th, .wpf-grid-lines td { border: 1px solid #dee2e6; }
.wpf-grid-lines th { background: #e9ecef; }

.btn-wpf-green, .btn-wpf-green2, .btn-wpf-gray, .btn-wpf-blue, .btn-wpf-orange, .btn-wpf-cyan, .btn-wpf-save, .btn-wpf-know {
  border: none; border-radius: 4px; color: #fff; height: 30px; padding: 0 14px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.btn-wpf-green, .btn-wpf-green2 { background: #28a745; }
.btn-wpf-green2 { background: #4CAF50; }
.btn-wpf-gray { background: #6c757d; }
.btn-wpf-blue { background: #2196F3; }
.btn-wpf-orange { background: #FF5722; }
.btn-wpf-cyan { background: #17A2B8; width: 100%; height: 36px; margin-top: 12px; }
.btn-wpf-save { background: #28A745; width: 100%; height: 40px; margin-top: 10px; font-size: 14px; }
.btn-wpf-know { background: #1976D2; width: 120px; height: 32px; border-radius: 6px; }
.btn-wpf-know:hover { background: #1565C0; }
.btn-wpf-link {
  background: none; border: none; color: #F44336; text-decoration: underline; cursor: pointer; font-size: 12px; padding: 0 8px;
}
.btn-wpf-link:hover { color: #1976D2; }
.btn-wpf-link-blue {
  background: none; border: none; color: #4A90E2; text-decoration: underline; cursor: pointer; font-size: 12px;
}

.log-toolbar, .mon-toolbar {
  background: #fff; border: 1px solid #ddd; border-radius: 4px; margin: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
}
.log-toolbar select, .mon-input {
  height: 28px; border: 1px solid #ccc; border-radius: 3px; padding: 0 6px; font-size: 12px;
}
.log-footer {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: #fff;
  border-top: 1px solid #e0e0e0; font-size: 12px; flex-shrink: 0;
}
.log-footer .c-green { color: #2e7d32; }
.log-footer .c-blue { color: #1565C0; }
.log-footer .c-red { color: #c62828; }
.spacer { flex: 1; }

.paired-stats { display: flex; gap: 14px; font-size: 12px; white-space: nowrap; }
.paired-stats .ps.blue b { color: #1565C0; }
.paired-stats .ps.green b { color: #2e7d32; }
.paired-stats .ps.orange b { color: #E65100; }

.mon-subtitle {
  display: flex; justify-content: space-between; padding: 6px 20px; font-size: 13px; background: #f5f5f5;
}
.mon-status { color: #666; font-size: 12px; }
.mon-auto { font-size: 12px; display: flex; align-items: center; gap: 4px; }

.ding-title { text-align: center; margin: 0 0 16px; font-size: 18px; color: #333; }
.ding-hint {
  background: #E3F2FD; border: 1px solid #BBDEFB; border-radius: 4px; padding: 10px 12px;
  font-size: 12px; color: #357ABD; margin: 12px 0;
}
.cfg-switch.risk { color: #C62828; font-weight: 600; }
.btn-wpf-save + .cfg-col, .cfg-col .btn-wpf-save { margin-top: 8px; }

.row-edit-footer {
  display: flex; justify-content: space-between; align-items: center; margin-top: 12px;
}
.disc-title { text-align: center; font-size: 20px; margin: 0 0 16px; }
.disc-scroll { max-height: 420px; }
.disc-footer {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 12px; height: 58px; justify-content: center;
}

@media (max-width: 1200px) {
  .wpf-win-history, .wpf-win-log, .wpf-win-paired, .wpf-win-monitor { width: 96vw; height: 85vh; }
}

/* 配置窗：对齐 WPF 30x16 小开关 */
.cfg-col-right { gap: 4px; }
.sw-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; border: 1px solid #E0E0E0; border-radius: 4px;
  background: #fff; padding: 0 6px 0 8px; margin: 0;
}
.sw-text { font-size: 11px; font-weight: 700; color: #212121; }
.sw-row.time-row { gap: 4px; }
.time-mini {
  width: 52px !important; height: 20px !important; font-size: 9px !important;
  border: 1px solid #E0E0E0 !important; border-radius: 2px; padding: 0 3px !important; text-align: center;
}
.time-sep { font-size: 11px; font-weight: 700; }

.mini-sw {
  position: relative; display: inline-flex; width: 30px; height: 16px;
  flex-shrink: 0; cursor: pointer; margin: 0; padding: 0; align-items: center;
}
.mini-sw input {
  position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none;
}
.mini-sw-track {
  display: block; width: 30px; height: 16px; border-radius: 8px;
  background: #E0E0E0; border: 1px solid #E0E0E0; position: relative;
  transition: background .15s ease;
}
.mini-sw-track::after {
  content: '';
  position: absolute; left: 1px; top: 1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: left .15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.mini-sw input:checked + .mini-sw-track {
  background: #4A90E2; border-color: #4A90E2;
}
.mini-sw input:checked + .mini-sw-track::after {
  left: 15px;
}

/* 压制 Bootstrap 把 checkbox 放大 */
.wpf-win-config input[type=checkbox],
.cfg-switch input[type=checkbox],
.mini-sw input[type=checkbox] {
  width: 0 !important; height: 0 !important;
  min-width: 0 !important; min-height: 0 !important;
  appearance: none !important; -webkit-appearance: none !important;
}
.wpf-win-config .cfg-row { min-height: 28px; }
.wpf-win-config .cfg-label { font-size: 11px; width: 70px; }
.wpf-win-config .cfg-row input,
.wpf-win-config .cfg-row select { height: 26px; font-size: 10px; }
.sw-inline {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 0 8px; height: 100%;
}
.sw-text.risk { color: #C62828; }
.wpf-win-config .cfg-row {
  grid-template-columns: 70px 1fr;
  height: 30px;
  margin: 2px 0;
}
.wpf-win-config .cfg-label {
  font-size: 11px; padding: 0 3px;
}

/* 可靠小开关：按钮 + 内圆点，不依赖 checkbox / ::after / Bootstrap */
button.mini-tog {
  display: inline-flex !important;
  align-items: center !important;
  width: 30px !important;
  height: 16px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  min-height: 16px !important;
  max-height: 16px !important;
  padding: 0 1px !important;
  margin: 0 !important;
  border: 1px solid #BDBDBD !important;
  border-radius: 8px !important;
  cursor: pointer;
  flex: 0 0 30px !important;
  box-shadow: none !important;
  outline: none !important;
  vertical-align: middle;
  line-height: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: none !important;
}
button.mini-tog.off { background: #E0E0E0 !important; justify-content: flex-start !important; }
button.mini-tog.on { background: #4A90E2 !important; border-color: #4A90E2 !important; justify-content: flex-end !important; }
button.mini-tog .mini-tog-knob {
  display: block !important;
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  flex-shrink: 0;
  pointer-events: none;
}
.sw-row button.mini-tog { margin-left: auto !important; }
