/* LatenZero — Dashboard Cards, Charts, War Room, Fluid Layout Editor & Responsive Grid */
/* =========================================================
   CARDS, KPIS & GRID LAYOUTS
   ========================================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.panel-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.panel-body {
  padding: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.grid-main-split {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 18px;
}
.grid-main-split.chart-expanded {
  grid-template-columns: 1fr;
}

/* =========================================================
   MULTI-AGENT VERIFICATION PIPELINE VISUALIZER
   ========================================================= */
.pipeline-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.agent-node {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.agent-node:hover { border-color: var(--border-default); transform: translateY(-1px); }
.agent-node.verdict-approve { border-top: 2px solid var(--green); }
.agent-node.verdict-veto, .agent-node.verdict-reject { border-top: 2px solid var(--red); }
.agent-node.verdict-warn { border-top: 2px solid var(--amber); }

.agent-node-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.agent-node-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.agent-node-role {
  font-size: 11px;
  color: var(--text-muted);
}

.score-bar {
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: var(--bg-subtle);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.35s ease;
}
.score-bar-fill.high { background: var(--green); }
.score-bar-fill.mid { background: var(--amber); }
.score-bar-fill.low { background: var(--red); }

.agent-node-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
}

.agent-node-rationale {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  min-height: 32px;
}

/* Badges & Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); }

/* Segmented Tabs */
.segmented {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 11px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.14s ease;
}
.segmented button.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   CHARTS (EXPANDED + ZOOM & PAN CONTROLS)
   ========================================================= */
.chart-stage {
  position: relative;
  width: 100%;
  height: 430px;
  user-select: none;
  touch-action: none;
}
.chart-stage.expanded {
  height: 550px;
}
.chart-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
.chart-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.chart-tool-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  height: 26px;
  min-width: 26px;
  padding: 0 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.13s ease, color 0.13s ease;
}
.chart-tool-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.chart-zoom-readout {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 6px;
  min-width: 56px;
  text-align: center;
}
.chart-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* =========================================================
   TABLES
   ========================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr {
  transition: background 0.12s ease;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr.clickable { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================================================
   AGENT CONFIG CARDS
   ========================================================= */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.agent-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.mini-stat-label { font-size: 10.5px; color: var(--text-muted); }
.mini-stat-val { font-size: 14px; font-weight: 700; margin-top: 2px; }

.agent-params-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* =========================================================
   MODAL & SLIDE-OVER INSPECTOR DRAWER
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.68);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body { padding: 20px; }

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.62);
  backdrop-filter: blur(3px);
  z-index: 65;
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.vote-detail-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  margin-bottom: 10px;
}

.metrics-kv {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.kv-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Toast Notifications */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: toastIn 0.2s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.spin {
  animation: spinAnim 0.85s linear infinite;
}
@keyframes spinAnim {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =========================================================
   REAL-TIME BINANCE WS PULSE & PRICE TICK FLASHES
   ========================================================= */
.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.22);
}
.ws-pill.reconnecting {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.25);
}
.ws-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: wsPulse 1.6s ease-in-out infinite;
}
@keyframes wsPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.tick-up {
  animation: flashGreen 0.55s ease;
}
.tick-down {
  animation: flashRed 0.55s ease;
}
@keyframes flashGreen {
  0% { color: var(--green); text-shadow: 0 0 10px rgba(16, 185, 129, 0.45); }
  100% { text-shadow: none; }
}
@keyframes flashRed {
  0% { color: var(--red); text-shadow: 0 0 10px rgba(244, 63, 94, 0.45); }
  100% { text-shadow: none; }
}

.ohlc-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* =========================================================
   AGENT WAR ROOM (LIVE INTER-AGENT DIALOGUE FEED)
   ========================================================= */
.warroom-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 486px;
  overflow-y: auto;
  padding-right: 4px;
}
.warroom-feed.tall {
  max-height: 580px;
}

.chat-msg {
  display: flex;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  animation: msgSlide 0.25s ease both;
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.type-execution {
  border-left: 3px solid var(--green);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), var(--bg-elevated) 48%);
}
.chat-msg.type-veto {
  border-left: 3px solid var(--red);
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.08), var(--bg-elevated) 48%);
}
.chat-msg.type-postmortem,
.chat-msg.type-lesson {
  border-left: 3px solid #a855f7;
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.09), var(--bg-elevated) 50%);
}
.chat-msg.type-decision {
  border-left: 3px solid var(--accent);
}

.agent-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
}
.av-alpha_ta { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.av-depth_guard { background: linear-gradient(135deg, #06b6d4, #0284c7); }
.av-oracle_sync { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.av-regime_pulse { background: linear-gradient(135deg, #f59e0b, #d97706); }
.av-risk_shield { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.av-quorum_arbiter { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.av-execution_desk { background: linear-gradient(135deg, #10b981, #059669); }
.av-meta_learner { background: linear-gradient(135deg, #c026d3, #7e22ce); }
.av-rl_policy { background: linear-gradient(135deg, #14b8a6, #0f766e); }

/* In-site Popup Confirmation Dialog Animation */
.modal {
  animation: modalPop 0.16s ease-out;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.rl-state-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rl-state-chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}


/* =========================================================
   CUSTOMIZABLE 12-COLUMN DRAG & RESIZE DASHBOARD GRID
   ========================================================= */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.dash-edit-banner {
  background: var(--bg-surface);
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.widget-chip-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.widget-vis-chip {
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}
.widget-vis-chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.widget-vis-chip:hover { border-color: var(--border-strong); }

/* Fluid Free-Form Flex Workspace (any continuous % width & exact px height — zero grid snapping!) */
.dash-grid {
  display: flex;
  flex-wrap: wrap;
  margin: -8px;
  align-items: flex-start;
}

.dash-widget {
  box-sizing: border-box;
  padding: 8px;
  min-width: 0;
  flex-grow: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.dash-widget-inner {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.16s ease, opacity 0.16s ease;
}

.dash-widget-inner > .panel,
.dash-widget-inner > .scalp-hero-bar,
.dash-widget-inner > .kpi-grid {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dash-widget-inner.has-fixed-h > .panel,
.dash-widget-inner.has-fixed-h > .scalp-hero-bar,
.dash-widget-inner.has-fixed-h > .kpi-grid {
  flex: 1 1 0%;
  overflow: hidden;
}

.dash-widget-inner > .kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  align-content: stretch;
}
.dash-widget-inner.has-fixed-h > .kpi-grid {
  overflow-y: auto;
}

.dash-widget-inner > .scalp-hero-bar {
  flex-direction: row;
}
.dash-widget-inner.has-fixed-h > .scalp-hero-bar {
  overflow-y: auto;
}

.dash-widget .panel-body-fill {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dash-widget-inner.has-fixed-h .panel-body-fill {
  flex: 1 1 0%;
}

.dash-widget .chart-stage-fill {
  min-height: 180px;
}
.dash-widget-inner.has-fixed-h .chart-stage-fill {
  flex: 1 1 0%;
  height: auto;
}

.dash-widget .warroom-feed-fill {
  min-height: 150px;
  max-height: 430px;
  overflow-y: auto;
}
.dash-widget-inner.has-fixed-h .warroom-feed-fill {
  flex: 1 1 0%;
  max-height: none;
}

.dash-widget .scroll-body-fill {
  min-height: 0;
  overflow-y: auto;
}
.dash-widget-inner.has-fixed-h .scroll-body-fill {
  flex: 1 1 0%;
}

/* Edit Mode Chrome on Each Widget */
.dash-grid.editing .dash-widget-inner {
  border-radius: var(--radius-lg);
  outline: 1.5px dashed rgba(99, 102, 241, 0.55);
  outline-offset: 2px;
}

.dash-widget.dragging .dash-widget-inner {
  opacity: 0.42;
  transform: scale(0.985);
}

.dash-widget.drop-target .dash-widget-inner {
  outline: 2px solid var(--green) !important;
  box-shadow: 0 0 0 5px var(--green-soft);
}

.dash-widget.resizing .dash-widget-inner {
  outline: 2px solid var(--accent) !important;
  box-shadow: 0 0 0 5px var(--accent-soft);
  z-index: 20;
  user-select: none;
}

.widget-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 11.5px;
  flex-wrap: wrap;
}

.dash-grid.editing .dash-widget-inner > .panel,
.dash-grid.editing .dash-widget-inner > .scalp-hero-bar {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.widget-drag-handle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: grab;
  padding: 2px 6px;
  border-radius: 6px;
  user-select: none;
}
.widget-drag-handle:hover { background: var(--bg-hover); }
.widget-drag-handle:active { cursor: grabbing; }

.widget-edit-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.w-col-btn,
.w-move-btn,
.w-autoh-btn,
.w-hide-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.13s ease;
}
.w-col-btn:hover,
.w-move-btn:hover,
.w-autoh-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.w-autoh-btn { display: none; }
.dash-widget-inner.has-fixed-h .w-autoh-btn { display: inline-flex; align-items: center; }
.w-col-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.w-hide-btn:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(244, 63, 94, 0.35);
}

/* Interactive Free Resize Handles */
.resize-handle {
  position: absolute;
  z-index: 15;
  touch-action: none;
}

.resize-handle-e {
  top: 38px;
  right: -5px;
  bottom: 20px;
  width: 10px;
  cursor: ew-resize;
}
.resize-handle-e::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 3.5px;
  height: 36px;
  transform: translateY(-50%);
  border-radius: 99px;
  background: var(--accent);
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.resize-handle-e:hover::after { opacity: 1; }

.resize-handle-s {
  left: 20px;
  right: 22px;
  bottom: -5px;
  height: 10px;
  cursor: ns-resize;
}
.resize-handle-s::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  height: 3.5px;
  width: 40px;
  transform: translateX(-50%);
  border-radius: 99px;
  background: var(--accent);
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.resize-handle-s:hover::after { opacity: 1; }

.resize-handle-se {
  right: 2px;
  bottom: 2px;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  opacity: 0.92;
}
.resize-handle-se:hover { opacity: 1; transform: scale(1.08); }

.resize-size-badge {
  position: absolute;
  right: 32px;
  bottom: 5px;
  z-index: 16;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
}

@media (max-width: 960px) {
  .dash-widget {
    flex-basis: 100% !important;
    width: 100% !important;
  }
  .resize-handle-e,
  .resize-handle-se {
    display: none;
  }
}

.chat-body {
  flex: 1;
  min-width: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.chat-sender-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-sender {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-arrow {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-mention {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 5px;
}

.chat-text {
  font-size: 12.8px;
  line-height: 1.48;
  color: var(--text-secondary);
  word-break: break-word;
}

.badge-purple {
  background: rgba(168, 85, 247, 0.16);
  color: #c084fc;
}
[data-theme="light"] .badge-purple {
  background: rgba(147, 51, 234, 0.12);
  color: #7e22ce;
}
.badge-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}
[data-theme="light"] .badge-cyan {
  background: rgba(6, 182, 212, 0.12);
  color: #0891b2;
}

/* Learning Adaptation Diff Pill */
.diff-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

/* =========================================================
   SCALPING CONTROL HERO BAR, PRESETS & SL→TP PROGRESS METER
   ========================================================= */
.scalp-hero-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.scalp-hero-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.scalp-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 700;
  background: var(--amber-soft);
  color: var(--amber);
}
.scalp-state-badge.running {
  background: var(--green-soft);
  color: var(--green);
}

.scalp-specs-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.scalp-spec-chip {
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.scalp-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Preset Cards in Settings */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.preset-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: inherit;
  font-family: inherit;
}
.preset-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.preset-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.preset-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.preset-name {
  font-size: 15px;
  font-weight: 700;
}

.preset-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

/* Active Scalp Position Card with Visual SL -> TP Track */
.scalp-pos-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scalp-pos-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scalp-pos-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sltp-track-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sltp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.sltp-track {
  position: relative;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(244, 63, 94, 0.25) 0%, var(--bg-subtle) 42%, rgba(16, 185, 129, 0.28) 100%);
  overflow: visible;
}

.sltp-marker {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
  transition: left 0.25s ease;
}
.sltp-marker.profit { background: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.sltp-marker.loss { background: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }

/* Friendly Info Callout Banner */
.info-banner {
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: var(--radius-md);
  padding: 12px 15px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.8px;
  color: var(--text-primary);
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sub-tab navigation bar */
.subtabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

@media (max-width: 960px) {
  .preset-grid { grid-template-columns: 1fr; }
}

/* Sidebar mobile backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
}

/* =========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================= */
@media (max-width: 1240px) {
  .pipeline-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main-split { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agents-grid, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1120px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 18px 8px;
    row-gap: 8px;
  }
  .topbar-ticker-wrap {
    order: 3;
    flex: 1 0 100%;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
  }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-collapse-btn { display: none; }
  .sidebar-backdrop.open { display: block; }
  .main-area { margin-left: 0; }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .topbar { padding: 10px 14px 8px; }
  .content { padding: 14px 14px 28px; }
  .live-meta { display: none; }
  .pipeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .kpi-grid, .pipeline-grid { grid-template-columns: 1fr; }
  .btn-label-hide-sm { display: none; }
  .topbar-actions .btn-sm {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }
  .topbar-actions .btn-icon {
    width: 34px;
    height: 34px;
  }
  .auth-card { padding: 28px 22px; }
}

/* Modular Dashboard History, Performance & AI Brain Cards */
.dash-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.14s ease;
}
.dash-history-row:hover {
  border-color: var(--border-default);
}

.dash-split-bar {
  height: 8px;
  border-radius: 99px;
  background: var(--red);
  overflow: hidden;
  display: flex;
}
.dash-split-win {
  height: 100%;
  background: var(--green);
  transition: width 0.35s ease;
}

.dash-mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.dash-mini-stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}
.dash-mini-stat strong {
  font-size: 12.8px;
}

.dash-rl-mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
}

@media (max-width: 640px) {
  .dash-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

