/* ── Piner — TradingView-style dark theme ──────────────────────────────── */

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

:root {
  --bg: #131722;
  --bg-2: #1a1e2e;
  --surface: #1a1e2e;
  --surface-2: #2a2e39;
  --surface-3: #363a45;
  --border: #2a2e39;
  --border-soft: #1f2230;
  --text: #d1d4dc;
  --text-dim: #787b86;
  --text-faint: #5d606b;
  --accent: #2962ff;
  --accent-soft: #1e3a6f;
  --success: #26a69a;
  --success-dim: #1f4d4a;
  --warning: #ffb300;
  --danger: #ef5350;
  --code-bg: #0d1117;
  --radius: 4px;
  --radius-lg: 6px;
  --font-mono: ui-monospace, "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 44px;
  --tab-h: 32px;
  --right-w: 340px;
  --right-collapsed-w: 40px;
  --transition: 180ms ease;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Top bar (TV-style) ───────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
}
.badge {
  font-size: 10px;
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.top-context {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-left: 16px;
  padding: 4px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  min-width: 0;
  max-width: 480px;
  flex-shrink: 1;
  overflow: hidden;
}
.ctx-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.ctx-chart {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elev, rgba(255,255,255,0.04));
  border: 1px solid var(--border, transparent);
}
.ctx-chart:focus-within { border-color: var(--accent); }
.ctx-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  outline: none;
  padding: 2px 4px;
  font-size: 14px;
}
#sym-input { width: 90px; font-weight: 600; text-transform: uppercase; }

/* TV-style symbol picker button (replaces the plain text input). */
.sym-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px 3px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 90px;
  letter-spacing: 0.3px;
  transition: background var(--transition), border-color var(--transition);
}
.sym-picker:hover { background: var(--bg-elev, rgba(255,255,255,0.06)); border-color: var(--accent); }
.sym-picker .ctx-caret { font-size: 9px; color: var(--text-faint); margin-left: 2px; }
#sym-label { text-transform: uppercase; }

#tf-input {
  width: 56px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
#tf-input option { background: var(--bg-2, #1a1a1a); color: var(--text); }
.ctx-slash { color: var(--text-faint); font-size: 14px; }
.ctx-strategy {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-primary { font-size: 12px; padding: 6px 12px; }

.top-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.top-right { display: flex; align-items: center; gap: 8px; margin-left: 12px; }

.notify-light {
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.notify-light.on { color: var(--success); border-color: var(--success-dim); }
.notify-light.error { color: var(--danger); border-color: var(--danger); }

/* ── Buttons (TV-flat) ───────────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 6px 12px;
  background: transparent;
  color: var(--text);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  user-select: none;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: transparent; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #1e4dd0; }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-ghost.danger:hover:not(:disabled) { color: var(--danger); }
.btn-ghost.active { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* ── Main layout ─────────────────────────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

/* Left column: error panel + chart. */
#chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* `hidden` 属性是浏览器默认 display:none,这里的规则要尊重它。 */
[hidden] { display: none !important; }

/* ── Error panel ─────────────────────────────────────────────────────── */
.error-panel {
  background: #2a1818;
  border-bottom: 1px solid var(--danger);
  flex-shrink: 0;
  max-height: 30vh;
  display: flex;
  flex-direction: column;
}
.error-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  border-bottom: 1px solid #4a2222;
}
#error-list {
  overflow-y: auto;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
}
.error-line { color: #ff8a80; padding: 1px 0; }
.error-line .error-loc { color: var(--text-faint); margin-left: 8px; }

/* ── Chart area ──────────────────────────────────────────────────────── */
#chart-container {
  flex: 1;
  background: var(--code-bg);
  position: relative;
  min-height: 200px;
  overflow: hidden;
}
.chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-faint);
  text-align: center;
  pointer-events: none;
  padding: 24px;
}
.chart-empty-title {
  font-size: 36px; font-weight: 300;
  color: var(--text-dim);
  margin-bottom: 12px;
  letter-spacing: 6px;
}
.chart-empty-hint { font-size: 12px; line-height: 2; }
.chart-empty kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--text-dim);
}
#chart-container.has-chart .chart-empty { display: none; }

.chart-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(26, 30, 46, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.5px;
  color: var(--text);
  pointer-events: none;
  z-index: 10;
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
}
.chart-overlay .indicators-list { pointer-events: auto; }
.overlay-status {
  font-size: 10px;
  color: var(--text-dim);
}
.overlay-status.running { color: var(--success); }
.overlay-status.error { color: var(--danger); }
.overlay-status.starting { color: var(--warning); }

/* ── Indicators: TV-style chips inside the chart title bar ──────────── */
/* (Sits inside .chart-overlay; no own background/border.) */
.indicators-panel {
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
}
.indicators-panel[hidden] { display: none; }
.indicators-list {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 60vw;
}
.indicator-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px 2px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 11px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  max-width: 180px;
  transition: background var(--transition), border-color var(--transition);
  vertical-align: middle;
  pointer-events: auto;
}
.indicator-chip:hover { background: var(--bg-elev, rgba(255,255,255,0.06)); }
.indicator-chip.primary { border-color: var(--accent); background: rgba(74, 158, 255, 0.1); }
.indicator-chip .chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.indicator-chip .chip-dot.running { box-shadow: 0 0 4px currentColor; animation: pulse 2s ease-in-out infinite; }
.indicator-chip .chip-dot.starting { background: var(--warning) !important; }
.indicator-chip .chip-dot.error { background: var(--danger) !important; }
.indicator-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}
.indicator-chip .chip-x {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 50%;
}
.indicator-chip .chip-x:hover { background: rgba(255,255,255,0.1); color: var(--text); }
/* TV-style: every running indicator gets a small bell button to create an alert on it. */
.indicator-chip .chip-bell {
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 120ms, background 120ms, color 120ms;
}
.indicator-chip:hover .chip-bell { opacity: 0.7; }
.indicator-chip .chip-bell:hover { opacity: 1; background: rgba(255, 180, 84, 0.18); color: #ffb454; }
.indicator-chip .chip-bell.active { opacity: 1; color: #ffb454; background: rgba(255, 180, 84, 0.15); }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-faint);
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.btn-icon:hover { background: var(--bg-elev, rgba(255,255,255,0.06)); color: var(--text); }
.btn-icon:active { transform: scale(0.92); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Right side: TV-style vertical icon column + slide-in panel ────── */
.right-side {
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  height: 100%;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.right-panel {
  position: relative;
  width: var(--right-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  transition: width var(--transition);
}
.right-panel[hidden] { display: none; }

.right-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--tab-h);
  padding: 0 8px 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
}
.right-panel-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right-panel-tabs { display: flex; align-items: center; gap: 4px; }
.right-panel-body { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.rpane { position: absolute; inset: 0; overflow-y: auto; padding: 6px 8px; }
.rpane[hidden] { display: none; }

/* Always-visible icon column on the far right. */
.right-icons {
  width: 48px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
}
.right-icon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: 52px;
  width: 100%;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: background 120ms, color 120ms;
}
.right-icon:hover { background: var(--surface-2); color: var(--text); }
.right-icon.active {
  background: var(--surface-2);
  color: var(--text);
  border-left-color: var(--accent);
}
.right-icon-glyph { font-size: 18px; line-height: 1; }
.right-icon-label { font-size: 9.5px; line-height: 1; }
.right-icon .tab-count {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 14px;
  line-height: 14px;
  padding: 0 4px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 600;
  border-radius: 7px;
  text-align: center;
}
.right-icon.active .tab-count { background: var(--accent-soft); color: var(--text); }
.right-icon.has-alerts .tab-count { background: var(--warning); color: var(--bg); }

/* Resizer on the left edge of the right panel. */
.panel-resizer {
  position: absolute;
  top: 0; bottom: 0; left: -3px;
  width: 6px;
  cursor: ew-resize;
  z-index: 5;
  user-select: none;
}
.panel-resizer:hover { background: var(--accent-soft); }
body.resizing { cursor: ew-resize !important; }
body.resizing * { user-select: none !important; cursor: ew-resize !important; }


/* (tab-count base moved into right-icon block; old bottom-tab/tab-pane removed.) */

/* Filter bar (shared by 通知 + 日志 tabs). */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.filter-chips { display: flex; gap: 2px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
.chip:hover { color: var(--text); background: var(--surface-3); }
.chip.active { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.chip-dot.ok { background: var(--success); }
.chip-dot.fail { background: var(--warning); }
.filter-select, .filter-search {
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  outline: none;
}
.filter-search { flex: 1; min-width: 80px; }
.filter-select:focus, .filter-search:focus { border-color: var(--accent); }
.filter-count {
  font-size: 10.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Watchlist (⭐ 自选). */
.watchlist-list { display: flex; flex-direction: column; gap: 1px; }
.watchlist-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  column-gap: 8px;
  padding: 5px 6px;
  font-size: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 120ms;
}
.watchlist-row:hover { background: var(--surface-2); }
.watchlist-row.active { background: var(--accent-soft); }
.watchlist-symbol {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.3px;
}
.watchlist-quote { font-size: 10.5px; color: var(--text-faint); }
.watchlist-price { font-family: var(--font-mono); font-size: 12px; color: var(--text); text-align: right; min-width: 70px; }
.watchlist-change { font-family: var(--font-mono); font-size: 10.5px; min-width: 56px; text-align: right; }
.watchlist-change.up { color: var(--success); }
.watchlist-change.down { color: var(--danger); }
.watchlist-change.flat { color: var(--text-faint); }
.watchlist-row .btn-ghost { padding: 1px 5px; font-size: 11px; opacity: 0; transition: opacity 120ms; }
.watchlist-row:hover .btn-ghost { opacity: 1; }
.watchlist-loading { color: var(--text-faint); font-size: 10.5px; }

/* Strategy dot (used in running strip + strategy cards) */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.status-dot.running { background: var(--success); box-shadow: 0 0 6px var(--success-dim); }
.status-dot.starting { background: var(--warning); }
.status-dot.error { background: var(--danger); }
.strategy-row .row-info { flex: 1; min-width: 0; }
.strategy-row .row-title {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Notifications list */
.notifications-list { display: flex; flex-direction: column; gap: 1px; }
.notification-row {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
}
.notification-row .notification-meta { color: var(--text-faint); font-size: 10.5px; }
.notification-row .notification-msg { color: var(--text); margin: 2px 0; }
.notification-row .notification-result { font-size: 10.5px; }
.notification-row.ok .notification-result { color: var(--success); }
.notification-row.fail .notification-result { color: var(--warning); }
.notification-row .notification-error {
  font-size: 10.5px;
  color: var(--warning);
  font-family: var(--mono, monospace);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.notification-row .notification-error:empty { display: none; }

/* Console / logs */
.console-output {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
}
.console-line { padding: 1px 0; }
.console-line.error { color: var(--danger); }
.console-line.success { color: var(--success); }
.console-line.info { color: var(--text-dim); }
.console-line.warn { color: var(--warning); }
.console-line .timestamp { color: var(--text-faint); margin-right: 6px; }
.console-line.highlight {
  background: rgba(255, 180, 84, 0.18);
  border-left: 2px solid var(--warning, #ffb454);
  padding-left: 6px;
  margin-left: -8px;
  animation: consoleHighlight 2.5s ease-out;
}
@keyframes consoleHighlight {
  0%   { background: rgba(255, 180, 84, 0.45); }
  60%  { background: rgba(255, 180, 84, 0.18); }
  100% { background: rgba(255, 180, 84, 0); border-left-color: transparent; margin-left: 0; padding-left: 1px; }
}

/* Notification row action buttons (jump to log / jump to chart). */
.notification-row .notification-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.notification-row .notification-actions .btn-ghost {
  font-size: 10.5px;
  padding: 1px 6px;
}

/* ── Right-panel "🚨 报警" tab — configured background alerts ────────── */
.bg-alerts-list { display: flex; flex-direction: column; gap: 1px; }
.bg-alert-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
  padding: 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background 120ms;
}
.bg-alert-row:hover { background: var(--surface-2, rgba(255,255,255,0.04)); }
.bg-alert-dot {
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bg-alert-dot.running { background: var(--success, #7ed957); box-shadow: 0 0 4px currentColor; animation: pulse 2s ease-in-out infinite; }
.bg-alert-dot.error { background: var(--danger, #e94560); }
.bg-alert-info { min-width: 0; overflow: hidden; }
.bg-alert-title { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-alert-target { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono, monospace); }
.bg-alert-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 10.5px; max-width: 110px; }
.bg-alert-interval { color: #ffb454; background: rgba(255, 180, 84, 0.12); border-radius: 3px; padding: 0 5px; font-weight: 600; }
.bg-alert-lastrun { color: var(--text-faint); font-size: 10px; }
.bg-alert-error { color: var(--warning, #ffb454); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.bg-alert-actions {
  grid-column: 2 / -1;
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}
.bg-alert-actions .btn-ghost { padding: 1px 6px; font-size: 11px; }

/* ── Modal (TV-style overlay) ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  animation: fadeIn 150ms ease;
}
.modal-window {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: modalIn 200ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { font-size: 13px; font-weight: 600; color: var(--text); }
.modal-header-actions { display: flex; gap: 4px; margin-left: auto; }
.editor-title-area { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.strategies-modal-window { width: 720px; max-width: 90vw; height: 70vh; max-height: 700px; }
.editor-modal-window { width: 95vw; height: 90vh; max-width: 1400px; }
.sym-modal-window { width: 560px; max-width: 90vw; max-height: 70vh; }

.modal-search {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.modal-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  outline: none;
}
.modal-search input:focus { border-color: var(--accent); }
.sym-search-hint {
  display: block;
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 5px;
  text-align: right;
}

.sym-status {
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--text-faint);
  text-align: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.sym-status.error { color: var(--danger); }
.sym-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.sym-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 12px;
  transition: background var(--transition);
}
.sym-row:hover, .sym-row.focused {
  background: var(--surface);
  border-left-color: var(--accent);
}
.sym-row .sym-ticker {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  min-width: 110px;
}
.sym-row .sym-quote {
  color: var(--text-faint);
  font-size: 10.5px;
  text-transform: uppercase;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  padding: 1px 5px;
}
.sym-row .sym-base {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sym-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 8px 14px 4px;
  background: var(--bg);
  border-top: 1px solid var(--border-soft);
}
.sym-row.current { border-left-color: var(--accent); }
.sym-row.current::after { content: "●"; color: var(--accent); margin-left: auto; font-size: 8px; }

.strategy-list-modal {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Strategy card (modal version) */
.strategy-list .strategy-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: default;
  transition: border-color var(--transition);
}
.strategy-list .strategy-card:hover { border-color: var(--border); }
.strategy-list .strategy-card.rendering { border-color: var(--accent); }
.strategy-list .strategy-card .card-info { flex: 1; min-width: 0; }
.strategy-list .strategy-card .card-title {
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.strategy-list .strategy-card .card-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.strategy-list .strategy-card .card-target {
  font-size: 11px;
  color: var(--accent);
  margin-top: 3px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.strategy-list .strategy-card .card-actions { display: flex; gap: 4px; }
.strategy-list .strategy-card .card-actions button { padding: 4px 10px; font-size: 11.5px; }
.strategy-list-empty { color: var(--text-faint); padding: 40px; text-align: center; font-size: 12px; }

/* Background-alert chip in the indicators strip — distinct from live chips. */
.indicator-chip.bg-chip {
  background: rgba(255, 180, 84, 0.08);
  border-color: rgba(255, 180, 84, 0.4);
}
.indicator-chip.bg-chip .chip-icon {
  font-size: 12px;
  line-height: 1;
}
.indicator-chip.bg-chip .chip-interval {
  font-size: 9.5px;
  text-transform: uppercase;
  color: #ffb454;
  background: rgba(255, 180, 84, 0.15);
  border-radius: 3px;
  padding: 0 4px;
  font-weight: 600;
}

/* ── Editor body ─────────────────────────────────────────────────────── */
.editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  gap: 10px;
  min-height: 0;
}
.editor-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.editor-hint {
  font-size: 11px;
  color: var(--text-faint);
  padding-bottom: 6px;
}
.editor-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}
.editor-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  text-transform: uppercase;
}
.editor-row input:focus { border-color: var(--accent); }

#pine-code {
  flex: 1;
  background: var(--code-bg);
  color: #c9d1d9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  resize: none;
  outline: none;
  line-height: 1.5;
  tab-size: 2;
  min-height: 0;
}
#pine-code:focus { border-color: var(--accent); }

.save-status { font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.save-status.unsaved { color: var(--warning); }
.save-status.saving { color: var(--text-dim); }
.save-status.saved { color: var(--success); }

/* ── Login page ──────────────────────────────────────────────────────── */
body.login-body {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #131722 0%, #1a1e2e 100%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 320px;
}
.login-card h1 { color: var(--text); font-size: 22px; text-align: center; font-weight: 600; letter-spacing: 1px; }
.login-card .subtitle { color: var(--text-dim); text-align: center; margin: 6px 0 24px; font-size: 12px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .btn-primary { width: 100%; padding: 10px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; gap: 4px; }
.login-card label input { width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); }
.login-error { color: var(--danger); font-size: 12px; text-align: center; }

/* ── Alert popover (TV-style: created from a running indicator) ───────── */
.alert-popover {
  position: fixed;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 10000;
  animation: alertPopoverIn 120ms ease;
}
@keyframes alertPopoverIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.alert-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.alert-popover-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.alert-popover-title { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-popover-target { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }
.alert-popover-state { font-size: 12px; color: #ffb454; background: rgba(255, 180, 84, 0.08); border: 1px solid rgba(255, 180, 84, 0.3); border-radius: 4px; padding: 8px 10px; }
.alert-popover-label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; gap: 4px; }
.alert-popover-label select {
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
}
.alert-popover-hint { font-size: 11px; color: var(--text-faint); line-height: 1.45; }
.alert-popover-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 2px; }

/* ── Batch-alert modal (one strategy × many symbols × many timeframes) ── */
.batch-modal-window { width: 720px; max-width: 92vw; height: 74vh; max-height: 760px; }
.batch-scroll { padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.batch-field { display: flex; flex-direction: column; gap: 6px; }
.batch-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.batch-inline-actions { display: flex; gap: 4px; }
.batch-label { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.batch-strategy { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-all; }
.batch-legend { font-size: 11px; color: var(--text-faint); line-height: 1.5; }
.batch-field select, .batch-paste {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: inherit;
  padding: 7px 9px;
  outline: none;
}
.batch-field select:focus, .batch-paste:focus { border-color: var(--accent); }
.batch-paste { resize: vertical; font-family: var(--mono); min-height: 40px; }
.batch-symbol-list, .batch-tf-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-height: 150px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.batch-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  font-family: var(--mono);
  white-space: nowrap;
}
.batch-check input { accent-color: var(--accent); cursor: pointer; }
.batch-empty { font-size: 12px; color: var(--text-faint); padding: 4px 2px; }
.batch-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg);
}
#batch-count { font-size: 13px; font-weight: 600; color: var(--accent); }
.batch-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.batch-footer .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
