body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
}

.helm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 16px;
  border-bottom: 1px solid #334155;
  padding-bottom: 10px;
}

.helm-tab {
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  border: 1px solid #334155;
  background: #0b1220;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
}

.helm-tab:hover {
  color: #e2e8f0;
  border-color: #475569;
}

.helm-tab-active {
  background: #1e293b;
  color: #f8fafc;
  border-bottom-color: #1e293b;
  margin-bottom: -1px;
}

.helm-tab-panel[hidden] {
  display: none;
}

.container {
  max-width: 1280px;
  margin: 20px auto;
  padding: 0 16px 32px;
}

h1, h2 {
  margin: 0 0 10px;
}

.muted {
  color: #94a3b8;
}

.small {
  font-size: 12px;
  line-height: 1.45;
}

.exec-row {
  margin: 8px 0;
}

.trade-mode-active-paper {
  background: #1d4ed8 !important;
  color: #fff;
}

.trade-mode-active-live {
  background: #b91c1c !important;
  color: #fff;
}

.exec-kite.mode-paper {
  background: #2563eb;
}

.exec-kite.mode-live {
  background: #b91c1c;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 15px;
}

.toggle-label input {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
}

.webhook-url-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.webhook-url {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #fde68a;
}

button.secondary {
  background: #334155;
}

.log-ok {
  color: #22c55e;
  font-weight: 600;
}

.log-fail {
  color: #f87171;
  font-weight: 600;
}

.mono {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-json {
  display: inline-block;
  overflow-wrap: anywhere;
  font-size: 11px;
  color: #a5b4fc;
}

.routing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 16px;
  margin: 12px 0;
}

.routing-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.routing-grid select {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
}

.bybit-manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 16px;
  margin: 12px 0;
}

.bybit-manual-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.bybit-manual-grid select {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
}

.small-input {
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px;
  max-width: 120px;
}

.routing-live {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
}

.modal-panel {
  position: relative;
  z-index: 1;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.modal-panel-wide {
  max-width: min(1200px, 98vw);
}

.modal-log-table {
  max-height: min(60vh, 520px);
  overflow: auto;
}

.signals-overview-wrap {
  overflow-x: auto;
}

.bracket-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

button.bracket-mini {
  font-size: 11px;
  padding: 4px 8px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.th-setup {
  width: 42px;
}

button.icon-btn {
  padding: 4px 8px;
  min-width: 36px;
  font-size: 16px;
  line-height: 1.2;
  background: #334155;
}

button.icon-btn:hover {
  background: #475569;
}

.leg-list {
  font-size: 11px;
  max-width: 220px;
  line-height: 1.35;
}

.signal-inst-cell {
  max-width: 360px;
  white-space: normal;
}

.signal-inst-line + .signal-inst-line {
  margin-top: 4px;
}

.card {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
  margin-top: 14px;
}

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

th, td {
  border-bottom: 1px solid #1f2937;
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #93c5fd;
}

input.small {
  width: 80px;
  background: #0b1220;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 5px;
}

button {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  margin-right: 6px;
  cursor: pointer;
}

button.abort {
  background: #dc2626;
}

button.exec-kite {
  background: #059669;
  margin-bottom: 6px;
  display: inline-block;
  width: 100%;
  max-width: 160px;
}

td.actions-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.pnl-pos {
  color: #22c55e;
  font-weight: 600;
}

.pnl-neg {
  color: #ef4444;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.signal-log-wrap {
  margin-top: 10px;
  border-radius: 8px;
  border: 1px solid #253041;
  background: #0a0f1a;
}

#signal-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

#signal-table th,
#signal-table td {
  border-bottom: 1px solid #1e293b;
}

#signal-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0f172a;
  color: #93c5fd;
  padding: 10px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 0 #334155;
}

#signal-table tbody tr.signal-log-row td {
  padding: 12px 10px;
  vertical-align: top;
}

#signal-table tbody tr.signal-group-a td {
  background: rgba(15, 23, 42, 0.92);
}

#signal-table tbody tr.signal-group-b td {
  background: rgba(30, 41, 59, 0.35);
}

#signal-table tbody tr.signal-log-row:hover td {
  background: rgba(51, 65, 85, 0.45);
}

#signal-table tbody tr.signal-log-sep td {
  border-top: 3px solid #64748b;
  padding-top: 18px;
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.15);
}

.signal-time-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
  min-width: 5.5rem;
}

.signal-time-date {
  font-size: 10px;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
}

.signal-time-clock {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  font-family: ui-monospace, monospace;
}

.signal-time-cell .signal-time-raw {
  white-space: normal;
}

#signal-table .signal-event-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  font-family: ui-monospace, monospace;
}

.signal-event-webhook {
  background: #1e3a5f;
  color: #7dd3fc;
  border: 1px solid #0369a1;
}

.signal-event-routing {
  background: #352764;
  color: #c4b5fd;
  border: 1px solid #6d28d9;
}

.signal-event-kite {
  background: #14532d;
  color: #86efac;
  border: 1px solid #15803d;
}

.signal-event-other {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
}

#signal-table .signal-plan-cell {
  max-width: 340px;
  white-space: normal;
  line-height: 1.45;
  font-size: 11px;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: unset;
  font-family: ui-monospace, monospace;
}

#signal-table .signal-order-cell,
#signal-table .signal-preview-cell,
#signal-table .signal-err-cell {
  max-width: 200px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#signal-table .signal-ok-cell,
#signal-table .signal-pos-cell {
  white-space: nowrap;
}

.kite-exit-wrap {
  max-width: 280px;
  font-size: 11px;
  line-height: 1.35;
}

.kite-exit-line + .kite-exit-line {
  margin-top: 4px;
}

.kite-exit-kind {
  font-weight: 700;
  color: #93c5fd;
  margin-right: 4px;
}

.kite-exit-st {
  color: #fde68a;
}

.kite-exit-td {
  vertical-align: top;
}
