*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --bg-card: #020617;
  --border-subtle: rgba(148, 163, 184, 0.28);
  --border-strong: rgba(148, 163, 184, 0.6);
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-soft-strong: rgba(79, 70, 229, 0.22);
  --text: #e5e7eb;
  --text-soft: #9ca3af;
  --text-softer: #6b7280;
  --danger: #f97373;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius-card: 18px;
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.65);
  --shadow-card: 0 14px 35px rgba(15, 23, 42, 0.55);
}

html[data-theme="light"] {
  --bg: #f4f5fb;
  --bg-card: #ffffff;
  --border-subtle: rgba(148, 163, 184, 0.4);
  --border-strong: rgba(148, 163, 184, 0.7);
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --accent-soft-strong: rgba(79, 70, 229, 0.15);
  --text: #020617;
  --text-soft: #4b5563;
  --text-softer: #6b7280;
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.08);
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #020617 0, #020617 45%, #020617 100%);
  color: var(--text);
}

html[data-theme="light"] body {
  background: radial-gradient(circle at top, #e5e7eb 0, #f4f5fb 45%, #eef2ff 100%);
}

/* Layout */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 26px) 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.layout-vertical {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.94),
      rgba(15, 23, 42, 0.88)
    );
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 10px;
  z-index: 10;
}

html[data-theme="light"] .topbar {
  background: rgba(248, 250, 252, 0.92);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.logo-circle {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #a5b4fc, #4f46e5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.86rem;
  color: white;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.5),
    0 9px 22px rgba(79, 70, 229, 0.6);
}

.brand-text h1 {
  margin: 0 0 2px;
  font-size: 0.98rem;
  font-weight: 600;
}

.brand-text p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cards */

.card {
  border-radius: var(--radius-card);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  padding: 14px 15px 14px;
}

.card-input {
  min-height: 230px;
}

.card-middle {
  min-height: 260px;
}

.card-output {
  min-height: 260px;
}

/* Card headers & footers */

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.card-header h2 {
  margin: 0 0 2px;
  font-size: 0.96rem;
}

.card-header p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.card-footer {
  margin-top: 9px;
}

.card-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Panels */

.panel {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 10px 11px 11px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.2), transparent 55%),
    rgba(15, 23, 42, 0.85);
}

html[data-theme="light"] .panel {
  background: linear-gradient(
    180deg,
    rgba(248, 250, 252, 0.96),
    rgba(241, 245, 249, 0.96)
  );
}

.panel-header h3 {
  margin: 0 0 2px;
  font-size: 0.9rem;
}

.panel-header p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-soft);
}

/* Footer */

.footer {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-softer);
  text-align: center;
}

/* Buttons & chips */

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 7px 13px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text);
  transition: border-color 0.16s ease, background-color 0.16s ease,
    box-shadow 0.16s ease, transform 0.07s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  border-color: rgba(129, 140, 248, 0.7);
  box-shadow: 0 7px 20px rgba(79, 70, 229, 0.65);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 11px 26px rgba(79, 70, 229, 0.75);
}

.btn-secondary {
  border-color: var(--accent-soft-strong);
  background: var(--accent-soft);
}

.btn-secondary:hover {
  background: var(--accent-soft-strong);
}

.btn-ghost {
  border-color: var(--border-subtle);
  background: rgba(15, 23, 42, 0.2);
}

html[data-theme="light"] .btn-ghost {
  background: rgba(248, 250, 252, 0.9);
}

.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.12);
}

.btn-compact {
  padding: 4px 10px;
  font-size: 0.72rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.icon-button {
  border-radius: 999px;
  width: 38px;
  height: 22px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.95);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

html[data-theme="light"] .icon-button {
  background: rgba(248, 250, 252, 0.95);
}

.icon-button span {
  flex: 1;
  text-align: center;
  opacity: 0.5;
}

/* Chips */

.chip {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  border: 1px solid var(--border-subtle);
}

.chip-muted {
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.7);
}

html[data-theme="light"] .chip-muted {
  background: rgba(248, 250, 252, 0.96);
}

/* Inputs */

.text-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  padding: 9px 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
}

html[data-theme="light"] .text-input {
  background: #f9fafb;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.8),
    0 0 0 4px rgba(129, 140, 248, 0.22);
}

.text-input-sm {
  font-size: 0.78rem;
}

.select {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 4px 9px;
  font-size: 0.78rem;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
}

html[data-theme="light"] .select {
  background: #f9fafb;
}

.field-label-inline {
  font-size: 0.78rem;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.hint-strong {
  font-size: 0.78rem;
  font-weight: 500;
}

/* Alerts */

.alert {
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 0.78rem;
}

.alert-error {
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-error ul {
  margin: 4px 0 0;
  padding-left: 16px;
}

/* Table */

.table-container {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.96);
}

html[data-theme="light"] .table-container {
  background: #f9fafb;
}

.fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.fields-table thead {
  background: rgba(15, 23, 42, 0.92);
  color: var(--text-soft);
}

html[data-theme="light"] .fields-table thead {
  background: rgba(248, 250, 252, 0.96);
}

.fields-table th,
.fields-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
}

html[data-theme="light"] .fields-table th,
html[data-theme="light"] .fields-table td {
  border-bottom: 1px solid rgba(226, 232, 240, 0.95);
}

.fields-table tbody {
  max-height: 260px;
  overflow-y: auto;
  display: block;
}

.fields-table thead tr,
.fields-table tbody tr {
  display: grid;
  grid-template-columns: 45% 12% 35% 8%;
  align-items: center;
}

.fields-table tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.8);
}

html[data-theme="light"] .fields-table tbody tr:nth-child(odd) {
  background: rgba(241, 245, 249, 0.95);
}

.placeholder-row td {
  text-align: center;
  color: var(--text-soft);
}

.field-title {
  font-size: 0.78rem;
  font-weight: 500;
}

.field-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.field-enums {
  margin-top: 1px;
  font-size: 0.7rem;
  color: var(--text-softer);
  max-height: 2.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-enums span.more {
  opacity: 0.85;
}

.field-input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 3px 8px;
  font-size: 0.78rem;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
}

html[data-theme="light"] .field-input {
  background: rgba(248, 250, 252, 0.96);
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(15, 23, 42, 1);
}

html[data-theme="light"] .field-input:focus {
  background: #ffffff;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.7;
}

.icon-btn:hover {
  opacity: 1;
}

/* enums eye button */
.icon-btn-eye {
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-softer);
}

.icon-btn-eye:hover {
  border-color: rgba(148, 163, 184, 0.65);
  background: rgba(15, 23, 42, 0.7);
}

html[data-theme="light"] .icon-btn-eye:hover {
  background: rgba(226, 232, 240, 0.9);
}

/* Derived section */

.divider {
  margin: 12px 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(148, 163, 184, 0.45),
    transparent
  );
}

.derived-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

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

.derived-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Form rows */

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

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

html[data-theme="light"] .modal-backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
  position: relative;
  max-width: 520px;
  width: 94%;
  max-height: 80vh;
  background: var(--bg-card);
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.85);
  padding: 14px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  margin: 0 0 2px;
  font-size: 0.96rem;
}

.modal-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.icon-btn-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.8;
}

.icon-btn-close:hover {
  opacity: 1;
}

.modal-body {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.8rem;
  max-height: 60vh;
  overflow-y: auto;
}

.enum-list {
  list-style: none;
  padding-left: 0;
  margin: 6px 0 0;
}

.enum-list li {
  padding: 3px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.25);
  display: flex;
  gap: 6px;
}

.enum-code {
  font-weight: 600;
  min-width: 32px;
}

/* Utilities */

.hidden {
  display: none;
}

/* Responsive */

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    border-radius: 18px;
  }

  .card-header,
  .card-footer-row,
  .derived-header,
  .form-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .button-row {
    width: 100%;
  }

  .button-row .btn {
    flex: 1;
    justify-content: center;
  }

  .fields-table thead tr,
  .fields-table tbody tr {
    grid-template-columns: 38% 14% 36% 12%;
  }

  .derived-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- MOBILE FIX: keep history dropdown inside the screen --- */
@media (max-width: 768px) {
  .header-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* make selects and button share space instead of pushing horizontally */
  .header-controls select,
  .header-controls button {
    flex: 1 1 100%;
    max-width: 100%;
  }

  /* avoid any horizontal overflow from the input card */
  .card-input {
    overflow-x: hidden;
  }
}

/* keep header dropdowns from stretching the layout */
.header-controls .select-sm {
  max-width: 100%;
}



/* Small select used in header controls */
.select-sm {
  font-size: 0.75rem;
  padding-block: 3px;
}

/* Header control row on input card */
.header-controls {
  align-items: center;
}

/* Validation + diff alerts */
.alert-warning {
  border: 1px solid #facc15;
  background: rgba(250, 204, 21, 0.08);
  color: #facc15;
}

html[data-theme="light"] .alert-warning {
  background: rgba(250, 204, 21, 0.08);
  color: #854d0e;
}

.alert-diff {
  border: 1px solid rgba(52, 211, 153, 0.7);
  background: rgba(16, 185, 129, 0.08);
  color: #6ee7b7;
  font-size: 0.78rem;
}

html[data-theme="light"] .alert-diff {
  background: rgba(16, 185, 129, 0.06);
  color: #047857;
}

/* Required rows */
.required-row td:first-child {
  border-left: 2px solid var(--accent);
  padding-left: 6px;
}

.required-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  border: 1px solid rgba(129, 140, 248, 0.7);
  padding: 1px 6px;
  font-size: 0.65rem;
  color: #a5b4fc;
  background: rgba(79, 70, 229, 0.2);
}

html[data-theme="light"] .required-badge {
  color: #4338ca;
  background: rgba(129, 140, 248, 0.18);
}


.creator-inline {
  margin: 1px 0 0;
  font-size: 0.7rem;
  color: var(--text-softer);
}

.creator-inline span {
  font-weight: 500;
}

.footer-creator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.footer-creator a {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.footer-creator a:hover {
  text-decoration-style: solid;
}

/* About icon button */
.icon-circle-btn {
  border-radius: 999px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.95);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-right: 4px;
}

html[data-theme="light"] .icon-circle-btn {
  background: rgba(248, 250, 252, 0.95);
}

.icon-circle-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}

/* v7 – clean log viewer, header exactly: Time | Message | ClOrdID | Detail | Sender | Target */

.log-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  margin-top: 16px;
}

.log-timeline-card,
.log-detail-card {
  min-width: 0;
}

/* inputs + filters */

.log-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-file input[type="file"] {
  font-size: 0.8rem;
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 8px 0 4px;
}

.log-status-inline {
  margin-left: auto;
  font-size: 0.75rem;
}

.log-table {
  margin-top: 4px;
}

/* rows & selection */

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.log-row {
  cursor: pointer;
}

.log-row:hover {
  background: rgba(148, 163, 184, 0.12);
}

.log-row-selected {
  background: rgba(59, 130, 246, 0.25);
}

/* pills for msg types */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
}

.pill-logon {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.pill-heartbeat {
  background: rgba(148, 163, 184, 0.18);
  color: #e5e7eb;
}

.pill-order {
  background: rgba(59, 130, 246, 0.2);
  color: #bfdbfe;
}

.pill-cancel {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.pill-replace {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
}

.pill-exec {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.pill-reject,
.pill-other {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

/* derived: open orders / positions */

.log-derived {
  margin-top: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.log-derived-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.log-tabs {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 999px;
  color: var(--text-soft);
}

.tab-btn-active {
  background: rgba(51, 65, 85, 0.9);
  color: var(--text);
}

/* helper */
.btn-small {
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* --- timeline table sizing --- */

.log-timeline-table {
  table-layout: fixed;
  width: 100%;
}

/* header cells: single line, left aligned */
.log-timeline-table th {
  white-space: nowrap;
  text-align: left;
  font-size: 0.8rem;
}

/* fixed column ratios matching header order */
.col-time   { width: 16%; }
.col-msg    { width: 16%; }
.col-clord  { width: 18%; }
.col-detail { width: 26%; }
.col-sender { width: 12%; }
.col-target { width: 12%; }

/* cells: prevent vertical text, but allow detail to wrap softly */
.log-timeline-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

/* Time / ClOrdID / Sender / Target stay on one line with ellipsis */
.log-timeline-table td:nth-child(1),
.log-timeline-table td:nth-child(2),
.log-timeline-table td:nth-child(3),
.log-timeline-table td:nth-child(5),
.log-timeline-table td:nth-child(6) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Detail column can wrap */
.log-timeline-table td:nth-child(4) {
  white-space: normal;
  word-break: break-word;
}

/* keep container from scrolling horizontally */
.table-container {
  overflow-x: hidden;
}



/* ================================
   LOG VIEWER LAYOUT & OVERRIDES
   ================================ */

/* overall layout for logs.html */
.log-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  margin-top: 16px;
}

.log-timeline-card,
.log-detail-card {
  min-width: 0;
}

/* filters / header bits */
.log-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-file input[type="file"] {
  font-size: 0.8rem;
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 8px 0 4px;
}

.log-status-inline {
  margin-left: auto;
  font-size: 0.75rem;
}

/* selection visuals */
.log-row {
  cursor: pointer;
}

.log-row:hover {
  background: rgba(148, 163, 184, 0.12);
}

.log-row-selected {
  background: rgba(59, 130, 246, 0.25);
}

/* pills for msg types */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
}

.pill-logon {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.pill-heartbeat {
  background: rgba(148, 163, 184, 0.18);
  color: #e5e7eb;
}

.pill-order {
  background: rgba(59, 130, 246, 0.2);
  color: #bfdbfe;
}

.pill-cancel {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.pill-replace {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
}

.pill-exec {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.pill-reject,
.pill-other {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

/* derived (open orders / positions) */
.log-derived {
  margin-top: 16px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.log-derived-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.log-tabs {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 999px;
  color: var(--text-soft);
}

.tab-btn-active {
  background: rgba(51, 65, 85, 0.9);
  color: var(--text);
}

/* --- TIMELINE TABLE: force real table layout, not grid --- */

.log-timeline-table {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
}

/* override global grid layout used for main editor table */
.log-timeline-table thead tr,
.log-timeline-table tbody tr {
  display: table-row;
  grid-template-columns: none;
}

/* override global tbody: make it a normal table section */
.log-timeline-table tbody {
  display: table-row-group;
  max-height: none;
  overflow-y: visible;
}

/* header cells */
.log-timeline-table th {
  white-space: nowrap;
  text-align: left;
  font-size: 0.8rem;
}

/* fixed column ratios, matching header order */
.col-time   { width: 16%; }
.col-msg    { width: 16%; }
.col-clord  { width: 18%; }
.col-detail { width: 26%; }
.col-sender { width: 12%; }
.col-target { width: 12%; }

/* body cells */
.log-timeline-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

/* single-line with ellipsis for narrow cols */
.log-timeline-table td:nth-child(1),
.log-timeline-table td:nth-child(2),
.log-timeline-table td:nth-child(3),
.log-timeline-table td:nth-child(5),
.log-timeline-table td:nth-child(6) {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* detail column can wrap */
.log-timeline-table td:nth-child(4) {
  white-space: normal;
  word-break: break-word;
}

/* avoid horizontal scroll on log tables */
.log-table {
  overflow-x: hidden;
}

/* --- FIX: highlight ALL rows on hover in log timeline --- */
.log-timeline-table tbody tr {
  background: transparent !important;
}

/* hover highlight for all rows */
.log-timeline-table tbody tr:hover {
  background: rgba(148, 163, 184, 0.15) !important;
}

/* selected row still looks selected */
.log-row-selected {
  background: rgba(59, 130, 246, 0.25) !important;
}

/* ================================
   LOG VIEWER – DERIVED + DETAIL TABLES
   ================================ */

/* Force true table layout for derived (Open Orders / Positions)
   and detail tables so headers align perfectly with cells. */
   .log-derived-table,
   .log-detail-table {
     table-layout: fixed;
     width: 100%;
     border-collapse: collapse;
   }
   
   /* Override the global grid-row layout just for these tables */
   .log-derived-table thead tr,
   .log-derived-table tbody tr,
   .log-detail-table thead tr,
   .log-detail-table tbody tr {
     display: table-row;
     grid-template-columns: none;
   }
   
   /* And override the block tbody so scrolling behaves like a normal table */
   .log-derived-table tbody,
   .log-detail-table tbody {
     display: table-row-group;
     max-height: none;
     overflow-y: visible;
   }
   
   /* Optional: tweak text wrapping for nicer look in detail table */
   .log-detail-table td:nth-child(1),
   .log-detail-table td:nth-child(2) {
     white-space: nowrap;
     text-overflow: ellipsis;
     overflow: hidden;
   }
   
   .log-detail-table td:nth-child(3),
   .log-detail-table td:nth-child(4) {
     white-space: normal;
     word-break: break-word;
   }
   