/* 国债基差监控 - 基础样式 */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

/* ============== 登录页 ============== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #0f172a);
}
.login-card {
  background: #fff;
  padding: 48px 40px;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.login-title {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  color: #1e3a8a;
}
.login-subtitle {
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 32px;
}
.login-card form { display: flex; flex-direction: column; gap: 8px; }
.login-card label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 12px;
}
.login-card input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: #1e3a8a; }
.login-card button {
  margin-top: 20px;
  padding: 12px;
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.login-card button:hover:not(:disabled) { background: #1e40af; }
.login-card button:disabled { opacity: 0.5; cursor: not-allowed; }
.error-msg { color: #dc2626; font-size: 12px; min-height: 16px; text-align: center; }
.login-hint { color: #9ca3af; font-size: 11px; text-align: center; margin-top: 16px; }

/* ============== Dashboard ============== */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* 页签导航 */
.tabs {
  display: flex;
  background: #f3f4f6;
  border-bottom: 1px solid #d1d5db;
  padding: 0 12px;
}
.tabs .tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
}
.tabs .tab:hover { color: #1e3a8a; }
.tabs .tab.active {
  color: #1e3a8a;
  border-bottom-color: #1e3a8a;
  background: #fff;
}
.tab-pane { flex: 1; overflow: auto; }

/* 副页签容器 */
.secondary-container { padding: 16px; }
.secondary-container h3 { margin: 0 0 12px 0; color: #1e3a8a; }

/* 副页签汇总 */
.sec-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.sum-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 16px;
}
.sum-box.sum-total {
  background: #eff6ff;
  border-color: #1e3a8a;
}
.sum-label { font-size: 11px; color: #6b7280; margin-bottom: 4px; }
.sum-value { font-size: 22px; font-weight: 600; color: #111827; font-family: 'Consolas', 'Monaco', monospace; }
.sum-value.pos { color: #16a34a; }
.sum-value.neg { color: #dc2626; }

/* 副页签操作按钮 */
.sec-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.sec-hint { font-size: 11px; color: #6b7280; margin-left: 8px; }

/* 副页签表格 */
.sec-table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow-x: auto;
}
.sec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.sec-table th, .sec-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f3f4f6;
  text-align: center;
  white-space: nowrap;
}
.sec-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
  z-index: 1;
}
.sec-table tr:hover { background: #f9fafb; }
.sec-table .sec-row-closed { background: #f3f4f6; color: #6b7280; }
.sec-table .sec-row-closed:hover { background: #e5e7eb; }
.sec-table .pnl-pos { color: #16a34a; font-weight: 600; }
.sec-table .pnl-neg { color: #dc2626; font-weight: 600; }
.sec-table .price-modified { color: #dc2626; font-weight: 600; }
.sec-table input.price-input {
  width: 80px;
  padding: 2px 4px;
  font-size: 12px;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  text-align: right;
  font-family: 'Consolas', 'Monaco', monospace;
}
.sec-table input.price-input.modified {
  color: #dc2626;
  border-color: #dc2626;
  font-weight: 600;
}
.sec-table input.price-input:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}
.sec-table .row-action-btn {
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  margin: 0 2px;
}
.sec-table .row-action-btn:hover { background: #f3f4f6; }
.sec-table .row-action-btn.btn-close { color: #f59e0b; border-color: #f59e0b; }
.sec-table .row-action-btn.btn-delete { color: #dc2626; border-color: #dc2626; }

/* 副页签新增 modal */
.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  min-width: 360px;
  max-width: 480px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.modal-box h3 { margin: 0 0 14px 0; color: #1e3a8a; font-size: 15px; }
.modal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.modal-row label {
  width: 100px;
  font-size: 12px;
  color: #6b7280;
  text-align: right;
}
.modal-row input {
  flex: 1;
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
}
.modal-row.modal-hint { padding: 4px 0; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}

.topbar {
  background: #1e3a8a;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-user { font-size: 12px; display: flex; align-items: center; gap: 16px; }
.topbar-user a { color: #bfdbfe; cursor: pointer; text-decoration: underline; }
.topbar-user a:hover { color: #fff; }

/* iFinD 连接状态指示器 (顶栏右上角) */
.ifind-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.1);
  transition: background 0.3s;
  cursor: default;
}
.ifind-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #9ca3af;  /* 默认灰 */
  transition: background 0.3s, box-shadow 0.3s;
}
.ifind-status.ifind-ok .ifind-dot { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.ifind-status.ifind-warn .ifind-dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; animation: ifind-pulse 1.2s infinite; }
.ifind-status.ifind-error .ifind-dot { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
.ifind-status.ifind-idle .ifind-dot { background: #6b7280; }
.ifind-status.ifind-unknown .ifind-dot { background: #9ca3af; }
@keyframes ifind-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* iFinD toast 横幅 (顶栏下方, 短时出现) */
.ifind-toast {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: ifind-toast-in 0.25s ease-out;
}
.ifind-toast-ok { background: #16a34a; color: #fff; }
.ifind-toast-warn { background: #f59e0b; color: #fff; }
.ifind-toast-error { background: #dc2626; color: #fff; }
@keyframes ifind-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.status-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 12px;
  flex-wrap: wrap;
}
.status-bar .item { display: flex; align-items: center; gap: 6px; }
.status-bar .label { color: #6b7280; }
.status-bar .value { font-weight: 500; }
.status-bar .green { color: #16a34a; }
.status-bar .red { color: #dc2626; }

.force-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 24px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.force-banner button {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.force-banner button:disabled { opacity: 0.5; cursor: not-allowed; }

.main {
  flex: 1 1 auto;
  min-height: 0;        /* 关键:允许子元素收缩 */
  display: grid;
  grid-template-columns: 380px 1fr 380px;
  gap: 16px;
  padding: 16px 24px;
  background: #f0f2f5;
  overflow: hidden;     /* 整体不滚动,内部自适应 */
}

.panel {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.panel h3 {
  font-size: 13px;
  font-weight: 600;
  color: #1e3a8a;
  margin-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 8px;
}

/* 持仓表 */
.position-table { width: 100%; font-size: 12px; }
.position-table th, .position-table td {
  padding: 6px 4px;
  text-align: right;
  border-bottom: 1px solid #f3f4f6;
}
.position-table th {
  color: #6b7280;
  font-weight: 500;
  text-align: right;
}
.position-table th:first-child, .position-table td:first-child { text-align: left; }
.position-table tr.level-3 { font-weight: 600; color: #1e3a8a; }

/* Z-Score gauge + summary */
.z-summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.z-row { display: flex; justify-content: space-between; font-size: 12px; }
.z-row .lbl { color: #6b7280; }
.z-row .val { font-weight: 600; font-family: monospace; }
.z-row .positive { color: #dc2626; }
.z-row .negative { color: #16a34a; }

.gauge-container { height: 200px; }

/* 参数编辑 */
.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}
.param-row label { color: #6b7280; }
.param-row input {
  width: 80px;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  text-align: right;
  font-family: monospace;
}
.param-row .grid-input { width: 75px; margin-left: 4px; }
.param-section { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid #f3f4f6; }
.param-section:last-child { border-bottom: none; }

/* Action buttons */
.actions {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 24px;
  display: flex;
  align-items: center;       /* 垂直居中 — 让 ? 图标和按钮中轴线对齐 */
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.btn:hover:not(:disabled) { background: #f9fafb; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-primary-active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4);
  animation: pulse-blue 1.5s ease-in-out infinite;
}
@keyframes pulse-blue {
  0%, 100% { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.1); }
}
.btn-tp-active {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.5);
  animation: pulse-red 1s ease-in-out infinite;
  font-weight: 600;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0.15); }
}
.btn-warning { background: #f59e0b; color: #fff; border-color: #f59e0b; }

/* 信号流 */
.signals {
  max-height: min(400px, calc(100vh - 540px));
  overflow-y: auto;
  font-size: 12px;
}
.signal-item {
  padding: 8px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.signal-source { color: #6b7280; font-size: 10px; }
.signal-action { font-weight: 600; }
.signal-action.action-OPEN_LEVEL { color: #16a34a; }
.signal-action.action-CLOSE_ALL { color: #dc2626; }
.signal-action.action-FORCE_CLOSE_REQUIRED { color: #f59e0b; }
.signal-meta { color: #6b7280; font-size: 11px; }
.signal-time { color: #9ca3af; font-size: 10px; }

/* 中间面板 (ECharts) — 高度响应式,优先 500px,小窗口自动缩 */
.chart-container { height: min(500px, calc(100vh - 460px)); margin-bottom: 12px; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi-card {
  background: #f9fafb;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}
.kpi-card .kpi-label { color: #6b7280; font-size: 11px; }
.kpi-card .kpi-value { font-size: 20px; font-weight: 600; color: #1e3a8a; font-family: monospace; margin-top: 2px; }
.kpi-card .kpi-sub { font-size: 10px; color: #9ca3af; margin-top: 2px; }

.threshold-bar,
.trigger-bar {
  height: 24px;
  background: linear-gradient(90deg, #16a34a 0%, #84cc16 30%, #eab308 50%, #f97316 70%, #dc2626 100%);
  border-radius: 4px;
  position: relative;
  margin: 8px 0;
}
.trigger-bar.tp-band {
  /* 跟开仓带用同一套绿→红渐变,保证两条带子颜色一致 */
  background: linear-gradient(90deg, #16a34a 0%, #84cc16 30%, #eab308 50%, #f97316 70%, #dc2626 100%);
  height: 24px;
}
.band-tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 24px;
  background: #1f2937;
  transform: translateX(-1px);
}
.band-tick span {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #374151;
  font-family: monospace;
  white-space: nowrap;
  background: #fff;
  padding: 0 2px;
}
.band-endpoint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #374151;
  font-family: monospace;
  font-weight: 600;
}
.band-endpoint[style*="left:0"] { left: 4px; }
.band-endpoint[style*="right:0"] { right: 4px; }
.band-marker {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 30px;
  background: #1e3a8a;
  border-radius: 2px;
  transform: translateX(-2px);
  z-index: 10;
}
.band-marker span {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #1e3a8a;
  font-weight: 600;
  background: #fff;
  padding: 0 3px;
  white-space: nowrap;
}
.band-marker.tp-marker {
  background: #dc2626;
}
.band-marker.tp-marker span { color: #dc2626; }

.threshold-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 16px;
  background: #1e3a8a;
  border-radius: 2px;
}
.threshold-marker::after {
  content: attr(data-label);
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #1e3a8a;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 32px 16px;
  font-size: 12px;
}
