/* ================== Reset & Tokens ================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* 中性灰阶 */
  --bg-app: #f7f8fa;
  --bg-panel: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-active: #eef0f3;
  --bg-input: #f9fafb;

  /* 边框 */
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* 文字 */
  --text-1: #111827;
  --text-2: #374151;
  --text-3: #6b7280;
  --text-4: #9ca3af;

  /* 强调 / 状态色（扁平，单色） */
  --accent: #111827;
  --accent-soft: #f3f4f6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --orange: #ea580c;       /* 标注线 / 重点强调 */

  /* K 线（中国习惯：红涨绿跌） */
  --candle-up: #ef4444;
  --candle-down: #22c55e;

  /* 阴影（极淡） */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 1px rgba(17, 24, 39, .03);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC',
               'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  background: var(--bg-app);
  color: var(--text-1);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================== Header ================== */
.header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.header-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-input);
  font-size: 18px;
  line-height: 1;
}
.header h1 { font-size: 15px; font-weight: 600; color: var(--text-1); letter-spacing: .2px; }

/* 手机端「切换股票」下拉（桌面默认隐藏） */
.header-stock-switcher {
  display: none;
  position: relative;
  margin-left: auto;
}
.header-stock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  max-width: 60vw;
}
.header-stock-btn .header-stock-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-stock-btn .ico { width: 12px; height: 12px; color: var(--text-3); }
.header-stock-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  min-width: 180px;
  max-width: 80vw;
  max-height: 60vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(17, 24, 39, .14);
  z-index: 80;
  padding: 4px;
}
.header-stock-menu[hidden] { display: none; }
.header-stock-menu .menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-1);
  cursor: pointer;
}
.header-stock-menu .menu-item:hover { background: var(--bg-hover); }
.header-stock-menu .menu-item.active { background: var(--accent); color: #fff; }
.header-stock-menu .menu-item.active .menu-code { color: rgba(255,255,255,.75); }
.header-stock-menu .menu-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-stock-menu .menu-code { color: var(--text-4); font-size: 11px; font-variant-numeric: tabular-nums; }
.header-stock-menu .menu-empty { padding: 10px; text-align: center; color: var(--text-4); font-size: 12px; }

/* 状态徽标 */
/* ================== Layout ================== */
.layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ================== Sidebar ================== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-header h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  flex: 1;
}
.add-stock-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg-input);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
}
.add-stock-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.add-stock-btn .ico { width: 12px; height: 12px; }

.stock-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.stock-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
  transition: background .12s;
}
.stock-item:hover { background: var(--bg-hover); }
.stock-item.active { background: var(--bg-active); }
.stock-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
/* ?all=1 模式下被隐藏的股票：名字变浅 + 显示「已隐藏」灰色标签 */
.stock-item.is-hidden .stock-name,
.stock-item.is-hidden .stock-code { opacity: 0.55; }
.stock-hidden-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 3px;
  vertical-align: middle;
}
.stock-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-1);
}
.stock-code {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.stock-meta {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 4px;
}
.stock-del {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-4);
}
.stock-del:hover { background: rgba(220, 38, 38, .08); color: var(--danger); }
.stock-item:hover .stock-del { display: inline-flex; }
.stock-del .ico { width: 13px; height: 13px; }

.empty-tip {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-4);
  font-size: 12px;
  line-height: 1.7;
}

/* ================== Main ================== */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 28px;
}

/* ================== Toolbar ================== */
.toolbar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.toolbar .grow { flex: 1; }
.toolbar .sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* Buttons —— 全部扁平 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn:active { background: var(--bg-active); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 13px; height: 13px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #1f2937;
  border-color: #1f2937;
}
.btn-dark {
  background: #111827;
  color: #fff;
  border-color: #111827;
  font-weight: 600;
  padding: 6px 18px;
}
.btn-dark:hover {
  background: #000;
  border-color: #000;
}
.btn-dark:disabled {
  background: #6b7280;
  border-color: #6b7280;
  cursor: not-allowed;
}
.btn-danger {
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover {
  background: rgba(220, 38, 38, .06);
  border-color: var(--danger);
}
.btn-orange {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.btn-orange:hover {
  background: #c2410c;
  border-color: #c2410c;
}

/* 选项控件 */
.opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-2);
}
.opt input[type=checkbox] {
  accent-color: var(--accent);
  cursor: pointer;
}
.opt input[type=number] {
  width: 38px;
  padding: 4px 4px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text-1);
}
.opt input[type=number]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.opt select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text-1);
  cursor: pointer;
}
.opt select:focus { outline: none; border-color: var(--accent); }

.fs-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.fs-btn {
  width: 22px; height: 24px;
  border: none;
  background: var(--bg-input);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
}
.fs-btn:hover { background: var(--bg-hover); }
.fs-val {
  min-width: 36px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
/* 天数输入框（替代纯展示的 .fs-val） */
input.fs-input {
  width: 44px;
  padding: 0 4px;
  border-top: none;
  border-bottom: none;
  outline: none;
  font-family: inherit;
  -moz-appearance: textfield;
  appearance: textfield;
}
input.fs-input::-webkit-outer-spin-button,
input.fs-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input.fs-input:focus {
  background: #fff7ed;
}
/* 工具栏紧凑日期输入 */
input.date-input {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  outline: none;
}
input.date-input:focus { border-color: var(--orange); background: #fff7ed; }

.status {
  font-size: 12px;
  color: var(--text-3);
  margin-left: 4px;
  min-height: 18px;
}

/* ================== Marker tags ================== */
.marker-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.marker-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-2);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.marker-tag .marker-x {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: var(--text-4);
}
.marker-tag .marker-x:hover { background: var(--danger); color: #fff; }
.marker-tag .marker-x .ico { width: 8px; height: 8px; }

/* ================== Panel ================== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  position: relative;
}
.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title .dim {
  color: var(--text-4);
  font-weight: 400;
  font-size: 11px;
}

/* ================== Chart area ================== */
.chart-wrap {
  position: relative;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}
.chart-wrap canvas {
  display: block;
  cursor: default;
  font-family: -apple-system, 'PingFang SC', sans-serif;
  touch-action: none;
}
.chart-hint {
  font-size: 11px;
  color: var(--text-4);
  margin-top: 8px;
  text-align: center;
}
.chart-hint .dim-sep {
  margin: 0 8px;
  color: var(--border-strong);
}
.chart-hint #viewInfo {
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ================== Pager bar (chart navigation) ================== */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.pager-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.pager-btn:active { background: var(--bg-active); }
.pager-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  background: var(--bg-input);
}
.pager-btn .ico { width: 11px; height: 11px; flex-shrink: 0; }
.pager-info {
  min-width: 220px;
  text-align: center;
  color: var(--text-3);
}
.pager-info b {
  color: var(--text-1);
  font-weight: 600;
}

.empty-chart {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-4);
  font-size: 13px;
  line-height: 1.8;
}
.empty-chart code {
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-2);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.empty-chart a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.empty-chart a:hover { text-decoration: underline; }

/* ================== Interval table ================== */
.iv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.iv-table th {
  background: var(--bg-input);
  color: var(--text-2);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.iv-table td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text-1);
}
.iv-table tr:hover td { background: var(--bg-hover); }
.iv-table tr:last-child td { border-bottom: 0; }

/* ================== Calc panel (量/额 累加计算) ================== */
.calc-block {
  margin-top: 12px;
}
.calc-block:first-of-type {
  margin-top: 8px;
}

/* 计算面板顶部工具条（按区间累加按钮） */
.calc-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.calc-toolbar .btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.calc-toolbar .btn-sm .ico { width: 14px; height: 14px; }
.calc-toolbar-tip {
  font-size: 12px;
  color: var(--text-3);
  flex: 1;
  min-width: 200px;
}

/* 「按区间累加」弹窗：左 1/3 表单 + 右 2/3 分时图 */
.interval-modal {
  display: flex;
  gap: 18px;
  align-items: stretch;
  min-width: 880px;
  max-width: min(1180px, 96vw);
}
.interval-modal-left {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
}
.interval-modal-right {
  flex: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.interval-chart-title {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
}
.interval-chart-legend {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.interval-chart-legend .lg-bar {
  display: inline-block;
  width: 16px; height: 10px;
  background: rgba(250, 204, 21, 0.35);
  border-left: 2px solid #f59e0b;
  border-right: 2px solid #f59e0b;
}
.interval-chart-wrap {
  position: relative;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-height: 280px;
  overflow: hidden;
}
.interval-chart-wrap canvas {
  display: block;
  width: 100%; height: 100%;
}
.interval-chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 13px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .interval-modal {
    flex-direction: column;
    min-width: auto;
    width: 90vw;
    gap: 10px;
  }
  .interval-modal-left, .interval-modal-right { flex: none; min-width: 0; }
  .interval-chart-wrap { min-height: 200px; }
}
.interval-date-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--bg-input);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.interval-date-hint {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
  margin-left: 4px;
}
.interval-time-row {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.interval-time-col {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.interval-time-col input[type="time"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--bg-input);
  color: var(--text);
}
.interval-result {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 14px 0 6px;
  text-align: center;
}
.interval-result-label {
  font-size: 12px;
  color: var(--text-3);
}
.interval-result-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}
.interval-result-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.calc-block-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  padding-left: 2px;
}
.calc-table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}
.calc-table {
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
  width: max-content;
}
.calc-table col.calc-col-label { width: 88px; }
.calc-table col.calc-col-data  { width: 120px; }
.calc-table tr.calc-row-name {
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.calc-table tr.calc-row-value td {
  background: #fff;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-1);
}
.calc-table tr.calc-row-aux td {
  background: #fff;
  color: var(--text-3);
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.calc-table tr.calc-row-aux:last-child td {
  border-bottom: 0;
}
.calc-table tr.calc-row-name td {
  padding: 6px 10px;
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-2);
  position: relative;
  border-right: 1px solid var(--border);
  min-width: 110px;
}
.calc-table tr.calc-row-name td:last-child { border-right: 0; }
.calc-table tr.calc-row-value td {
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.calc-table tr.calc-row-value td:last-child { border-right: 0; }
.calc-table tr.calc-row-aux td {
  padding: 4px 10px;
  text-align: center;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}
.calc-table tr.calc-row-aux td:last-child { border-right: 0; }
.calc-table tr.calc-row-name td.calc-label,
.calc-table tr.calc-row-value td.calc-label,
.calc-table tr.calc-row-aux td.calc-label {
  background: var(--bg-input);
  color: var(--text-3);
  font-weight: 600;
  text-align: right;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 80px;
}
.calc-table .calc-type-tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 3px;
  margin-left: 4px;
  font-weight: 600;
  vertical-align: 1px;
}
.calc-type-tag.t-volume { background: #dbeafe; color: #1d4ed8; }
.calc-type-tag.t-amount { background: #fee2e2; color: #b91c1c; }
.calc-table .calc-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 3px;
  border: 0;
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  margin-left: 4px;
  vertical-align: 1px;
}
.calc-table .calc-del:hover { background: #fee2e2; color: #b91c1c; }
/* 分时计算记录格子可点击查看 */
.calc-table td[data-action="view-intraday-calc"] { cursor: pointer; }
.calc-table td[data-action="view-intraday-calc"]:hover { background: #f3f4f6; }
.calc-table .calc-draft-input {
  width: 90px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}
.calc-table .calc-draft-input:focus {
  border-color: var(--orange);
}
.calc-table .calc-draft-actions {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.calc-table .calc-mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.calc-table .calc-mini-btn.ok { color: var(--orange); border-color: var(--orange); }
.calc-table .calc-mini-btn.ok:hover { background: var(--orange); color: #fff; }
.calc-table .calc-mini-btn.cancel:hover { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.calc-table tr.calc-row-name td.calc-draft-cell {
  background: #fff7ed;
}
.calc-table tr.calc-row-value td.calc-draft-cell,
.calc-table tr.calc-row-aux td.calc-draft-cell {
  background: #fff7ed;
}
.calc-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-4);
}

/* ================== Calc 草稿浮框（双击 / 拖框时浮现） ================== */
.calc-float {
  position: fixed;
  z-index: 90;
  background: #fff;
  border: 1px solid var(--orange);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(17, 24, 39, 0.16);
  padding: 8px 12px;
  min-width: 168px;
  font-size: 12px;
  pointer-events: auto;
  animation: cfPop 0.12s ease-out;
}
.calc-float .cf-block + .cf-divider + .cf-block { margin-top: 0; }
.calc-float .cf-divider {
  height: 1px;
  background: var(--border);
  margin: 8px -12px;
}
@keyframes cfPop {
  from { opacity: 0; transform: translateY(2px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.calc-float .cf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.calc-float .cf-tag {
  font-weight: 600;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
}
.calc-float .cf-tag.t-volume { background: #dbeafe; color: #1d4ed8; }
.calc-float .cf-tag.t-amount { background: #fee2e2; color: #b91c1c; }
.calc-float .cf-count {
  color: var(--text-3);
  font-size: 11px;
}
.calc-float .cf-value {
  font-weight: 700;
  font-size: 18px;
  color: #dc2626;
  letter-spacing: 0.2px;
  line-height: 1.2;
  margin-bottom: 8px;
}
.calc-float .cf-actions {
  display: flex;
  gap: 6px;
}
.calc-float .cf-btn {
  flex: 1;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.calc-float .cf-btn.ok {
  border-color: var(--orange);
  color: var(--orange);
}
.calc-float .cf-btn.ok:hover {
  background: var(--orange);
  color: #fff;
}
.calc-float .cf-btn.cancel:hover {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* 保存计算 modal 里的"当前累加结果"摘要 */
.calc-modal-summary {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}
.calc-modal-summary b { color: #dc2626; font-size: 14px; }

/* ================== Modal ================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 380px;
  max-width: 90vw;
  padding: 22px 24px 20px;
  box-shadow: 0 16px 48px rgba(17, 24, 39, .15),
              0 4px 12px rgba(17, 24, 39, .08);
}
.modal h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin: 12px 0 5px;
  font-weight: 500;
}
.modal input[type=text] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-1);
}
.modal input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ================== Toast ================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-1);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.toast.show { opacity: 1; }

/* ================== Loading ================== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .9);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-radius: var(--radius);
  z-index: 5;
  font-size: 12px;
  color: var(--text-2);
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================== Toggle Switch ================== */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.switch input { display: none; }
.switch-track {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background .18s;
  flex-shrink: 0;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .25);
  transition: left .18s;
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track .switch-thumb {
  left: 16px;
}
.switch:hover .switch-track {
  background: #b9bec6;
}
.switch:hover input:checked + .switch-track {
  background: #1f2937;
}
.switch-label { letter-spacing: .2px; }

/* ================== Intraday Popout ================== */
.intraday-popout {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 50vw;
  height: 50vh;
  min-width: 480px;
  min-height: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-right: none;
  border-bottom: none;
  border-top-left-radius: var(--radius-lg);
  box-shadow: -8px -8px 32px rgba(17, 24, 39, .08),
              -2px -2px 8px rgba(17, 24, 39, .04);
  display: flex;
  flex-direction: column;
  z-index: 80;
  transform: translate(100%, 100%);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}
.intraday-popout.show {
  transform: translate(0, 0);
  opacity: 1;
  pointer-events: auto;
}
.ip-header {
  height: 40px;
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
}
.ip-header.dragging { cursor: grabbing; }
.ip-header > * { cursor: default; }
.ip-header .ip-close { cursor: pointer; }
/* 浮窗被拖动后用绝对定位 */
.intraday-popout.dragged {
  right: auto;
  bottom: auto;
  transform: none;
  transition: none;
}
.intraday-popout.dragged.show { transform: none; }
.ip-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  min-width: 0;
}
.ip-symbol {
  font-weight: 600;
  color: var(--text-1);
}
.ip-date {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.ip-change {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.ip-meta {
  margin-left: auto;
  color: var(--text-4);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.ip-close {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
  margin-left: 8px;
}
.ip-close:hover { background: var(--bg-hover); color: var(--text-1); }
.ip-close .ico { width: 11px; height: 11px; }

.ip-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fff;
}
.ip-body canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.ip-loading {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .94);
  font-size: 12px;
  color: var(--text-2);
  z-index: 2;
}
.ip-loading.show { display: flex; }
.ip-loading .spinner { margin-bottom: 8px; }
.ip-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: var(--text-4);
  padding: 0 16px;
  z-index: 1;
  line-height: 1.7;
}
.ip-hint {
  height: 26px;
  font-size: 11px;
  color: var(--text-4);
  text-align: center;
  line-height: 26px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ================== Hidden file ================== */
input[type=file].hidden-file { display: none; }

/* ================== Scrollbar (subtle) ================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(17, 24, 39, .12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(17, 24, 39, .22); }

/* ================== 标注网格（手机端替代 canvas 底部标注表） ================== */
.marker-grid {
  display: none;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.marker-grid .mg-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}
.marker-grid .mg-cell {
  padding: 6px 4px;
  text-align: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.marker-grid .mg-cell:nth-child(4n) { border-right: 0; }
.marker-grid .mg-row-date  .mg-cell { background: var(--bg-input); color: var(--text-3); font-size: 11px; }
.marker-grid .mg-row-price .mg-cell { background: #fff; color: var(--text-1); font-weight: 600; }
.marker-grid .mg-row-amt   .mg-cell { background: #fff; color: var(--text-2); font-size: 11px; border-bottom: 0; }
.marker-grid .mg-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-4);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

/* ================== 标注网格（手机端替代 canvas 内底部表） ================== */
.marker-grid { display: none; }       /* 桌面默认隐藏 */
.marker-grid .mg-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 10px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.marker-grid .mg-row {
  display: contents;
}
.marker-grid .mg-cell {
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.marker-grid .mg-row.mg-row-date .mg-cell {
  background: var(--bg-input);
  font-weight: 600;
  color: var(--text-2);
  font-size: 11px;
}
.marker-grid .mg-row.mg-row-price .mg-cell {
  font-weight: 600;
  color: var(--text-1);
}
.marker-grid .mg-row.mg-row-amount .mg-cell {
  color: var(--text-3);
  font-size: 11px;
  border-bottom: 0;
}
.marker-grid .mg-cell:nth-child(4n) { border-right: 0; }

/* ================== 手机端适配（≤ 768px） ================== */
@media (max-width: 768px) {
  /* 左侧栏隐藏（用顶部下拉切换股票） */
  .sidebar { display: none; }

  /* 工具栏整条隐藏 */
  .toolbar { display: none !important; }

  /* 顶部下拉显示 */
  .header-stock-switcher { display: block; }

  /* main 全宽 + 内边距收紧 */
  .main { padding: 10px 10px 18px; }

  /* 顶 logo 文案再收一下 */
  .header { padding: 0 12px; gap: 10px; }
  .header h1 { font-size: 14px; }

  /* 计算面板 / 图表 panel 内边距收紧 */
  .panel { padding: 10px !important; }

  /* 区间数据表水平滚动 */
  #intervalSec { overflow-x: auto; }

  /* K 线 canvas 强制 100% 宽 */
  #chartWrap { overflow: hidden; }
  #chartWrap canvas { width: 100% !important; max-width: 100%; display: block; }

  /* 标注网格显示（替代 canvas 内底部标注表） */
  .marker-grid { display: block; }

  /* 分页栏在小屏更紧凑 */
  .pager { gap: 4px; }
  .pager-btn { padding: 4px 6px; font-size: 11px; }
  .pager-info { font-size: 11px; }

  /* 分时浮窗在手机上占满 */
  .intraday-popout {
    width: calc(100vw - 16px) !important;
    height: 56vh !important;
    right: 8px !important;
    left: 8px !important;
    bottom: 8px !important;
  }
}

/* 显示设置 弹窗 */
#settingsModalMask .modal {
  min-width: 320px;
}
#settingsModalMask .settings-row {
  margin: 8px 0;
  display: flex;
  align-items: center;
}
#settingsModalMask .settings-hint {
  margin-left: 6px;
  font-size: 12px;
}
#settingsModalMask .settings-tip {
  margin: 12px 0 6px;
  font-size: 12px;
  color: #6b7280;
}
