.bots-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-5);
  height: calc(100vh - 100px);
  align-items: start;
}

.bots-sidebar {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.bots-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.bots-sidebar-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-primary);
}

.bots-sidebar-header .btn-primary {
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  background: var(--status-success);
  border-color: var(--status-success);
  color: #0a0e14;
  font-weight: 600;
}

.bots-sidebar-header .btn-primary::before {
  content: '+ ';
}

.bots-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow-y: auto;
  flex: 1;
  padding-right: var(--space-1);
}

.bots-list-empty {
  color: var(--fg-tertiary);
  font-style: italic;
  font-size: var(--fs-sm);
  padding: var(--space-4) 0;
  text-align: center;
}

.bot-list-item {
  position: relative;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}

.bot-list-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-default);
}

.bot-list-item:hover {
  background: var(--bg-elev-3);
  border-color: var(--border-strong);
}

.bot-list-item.active {
  background: var(--bg-elev-3);
  border-color: var(--accent-cyan);
}

.bot-list-item.active::before {
  background: var(--accent-cyan);
}

.bot-list-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.bot-list-item-symbol {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.bot-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-inactive);
  flex-shrink: 0;
}

.bot-status-dot.running {
  background: var(--status-success);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}
.bot-status-dot.stopped { background: var(--status-inactive); }
.bot-status-dot.paused { background: var(--status-warning); }
.bot-status-dot.error { background: var(--status-danger); }

.bot-list-item-meta {
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.03em;
}

.bots-main {
  background: var(--bg-elev-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

.bots-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--fg-tertiary);
  font-style: italic;
  font-size: var(--fs-md);
}

.bots-empty-state[hidden] { display: none; }

.bots-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.bots-detail-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

#bot-detail-symbol {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fg-primary);
  line-height: 1.1;
}

.bots-detail-strategy {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-tertiary);
}

.bots-detail-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.bot-status-pill {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  color: var(--fg-tertiary);
}

.bot-status-pill.running {
  color: var(--status-success);
  border-color: var(--status-success);
  background: rgba(74, 222, 128, 0.08);
}

.bot-status-pill.stopped {
  color: var(--fg-tertiary);
  border-color: var(--border-default);
}

.bot-status-pill.paused {
  color: var(--status-warning);
  border-color: var(--status-warning);
  background: rgba(255, 181, 71, 0.08);
}

.bot-status-pill.error {
  color: var(--status-danger);
  border-color: var(--status-danger);
  background: rgba(248, 113, 113, 0.08);
}

.auto-refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-tertiary);
  font-size: var(--fs-sm);
  cursor: pointer;
  padding: 0 var(--space-2);
}

.auto-refresh-toggle input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

.bots-metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.bots-metrics-grid .metric {
  position: relative;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow: hidden;
}

.bots-metrics-grid .metric::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-cyan);
}

.bots-metrics-grid .metric:nth-child(1)::before { background: var(--accent-cyan); }
.bots-metrics-grid .metric:nth-child(2)::before { background: var(--accent-blue); }
.bots-metrics-grid .metric:nth-child(3)::before { background: var(--status-warning); }
.bots-metrics-grid .metric:nth-child(4)::before { background: var(--accent-magenta); }
.bots-metrics-grid .metric:nth-child(5)::before { background: var(--status-success); }
.bots-metrics-grid .metric:nth-child(6)::before { background: var(--status-danger); }

.bots-metrics-grid .metric-label {
  color: var(--fg-tertiary);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.bots-metrics-grid .metric-value {
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1;
  margin: 0;
}

.bots-section {
  margin-bottom: var(--space-6);
}

.bots-section h3 {
  margin: 0 0 var(--space-3) 0;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-tertiary);
}

.bot-open-position {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  align-items: center;
  min-height: 60px;
}

.bot-open-position .empty-msg {
  grid-column: 1 / -1;
  color: var(--fg-tertiary);
  font-style: italic;
  text-align: left;
  font-size: var(--fs-sm);
}

.position-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.position-field-label {
  color: var(--fg-tertiary);
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.position-field-value {
  color: var(--fg-primary);
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.position-field-value.long { color: var(--bull); }
.position-field-value.short { color: var(--bear); }

.position-field:nth-child(3) .position-field-value { color: var(--bear); }
.position-field:nth-child(4) .position-field-value { color: var(--bull); }

.bot-events-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
}

.bot-events-list .empty-msg {
  padding: var(--space-4);
  color: var(--fg-tertiary);
  font-style: italic;
  text-align: center;
}

.bot-event-item {
  position: relative;
  display: grid;
  grid-template-columns: 80px 180px 1fr;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  align-items: center;
}

.bot-event-item:last-child { border-bottom: none; }

.bot-event-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.bot-event-item.position_opened::before { background: var(--status-success); }
.bot-event-item.position_closed::before { background: var(--accent-blue); }
.bot-event-item.order_rejected::before { background: var(--status-warning); }
.bot-event-item.engine_started::before { background: var(--accent-cyan); }
.bot-event-item.engine_stopped::before { background: var(--status-inactive); }
.bot-event-item.position_modified::before { background: var(--accent-magenta); }
.bot-event-item.error::before { background: var(--status-danger); }

.bot-event-time {
  color: var(--fg-tertiary);
  font-size: var(--fs-xs);
}

.bot-event-type {
  color: var(--fg-primary);
  font-weight: 600;
}

.bot-event-detail {
  color: var(--fg-secondary);
  font-size: var(--fs-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-trades-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 350px;
  overflow-y: auto;
}

.bot-trades-list .empty-msg {
  padding: var(--space-4);
  color: var(--fg-tertiary);
  font-style: italic;
  text-align: center;
}

.bot-trade-item {
  position: relative;
  display: grid;
  grid-template-columns: 80px 80px 1fr 1fr 100px 80px;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  align-items: center;
}

.bot-trade-item:last-child { border-bottom: none; }
.bot-trade-item:hover { background: var(--bg-elev-3); }

.bot-trade-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-default);
}

.bot-trade-item.win::before { background: var(--bull); }
.bot-trade-item.loss::before { background: var(--bear); }

.bot-trade-item > span:first-child {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  color: var(--fg-primary);
}

.bot-trade-item.win > span:nth-child(5) { color: var(--bull); }
.bot-trade-item.loss > span:nth-child(5) { color: var(--bear); }

.bot-trade-item > span:nth-child(2) {
  color: var(--fg-secondary);
  font-weight: 600;
}

.bot-trade-item > span:nth-child(6) {
  color: var(--fg-tertiary);
  font-size: var(--fs-xs);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] { display: none; }

.modal-content {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 480px;
  width: 90%;
}

.modal-content h3 {
  margin: 0 0 var(--space-4) 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  color: var(--fg-primary);
}

.modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

@media (max-width: 1280px) {
  .bots-metrics-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .bots-layout { grid-template-columns: 1fr; height: auto; }
  .bots-sidebar { height: auto; max-height: 300px; }
  .bots-metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .bot-open-position { grid-template-columns: repeat(2, 1fr); }
}
