.metrics-pre {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  padding: 12px;
  font-size: 0.78rem;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  color: inherit;
}

.rec-item-error { border-left: 3px solid #dc3545; }
.rec-item-warning { border-left: 3px solid #ffc107; }
.rec-item-info { border-left: 3px solid #17a2b8; }

.rec-formula {
  font-size: 0.75rem;
  opacity: 0.75;
  font-family: ui-monospace, monospace;
}

.field-hint {
  font-size: 0.75rem;
  opacity: 0.7;
}

.config-input-changed {
  box-shadow: 0 0 0 2px rgba(23, 162, 184, 0.45);
}

/* Account balance */
.account-balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

.account-balance-label {
  opacity: 0.65;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.account-balance-value {
  font-weight: 600;
  color: #5bc0de;
}

.account-balance-addr {
  opacity: 0.5;
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-balance-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0.65;
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  color: inherit;
  text-decoration: none;
  max-width: 140px;
}

.account-balance-link:hover {
  opacity: 1;
  color: #5bc0de;
  text-decoration: none;
}

.account-balance-link-icon {
  font-size: 0.6rem;
  opacity: 0.7;
}

/* siQtheme header/sidebar responsive (complements siqtheme.css _media.scss) */
@media screen and (max-width: 768px) {
  .header .navigation {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    padding-right: 8px;
  }

  .header .navigation .navbar-menu {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #account-balance.account-balance {
    margin-right: 0 !important;
    max-width: calc(100vw - 100px);
    padding: 4px 10px;
    font-size: 0.78rem;
  }

  .account-balance-label {
    display: none;
  }

  .account-balance-link {
    max-width: 96px;
  }

  #btn-logout {
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
  }

  #bot-status-badge,
  #mode-badge,
  #role-badge {
    font-size: 0.68rem;
  }
}

@media screen and (max-width: 480px) {
  .header .navigation .navbar-menu .badge {
    margin-left: 0.25rem !important;
  }

  #account-balance.account-balance {
    width: 100%;
    max-width: none;
    justify-content: flex-end;
  }
}

/* Bot cards */
.bot-card {
  margin-bottom: 1.25rem;
}

.bot-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bot-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.bot-card-id {
  font-size: 0.75rem;
  opacity: 0.55;
  font-family: ui-monospace, monospace;
}

.bot-card-meta {
  font-size: 0.82rem;
  opacity: 0.75;
  margin-top: 4px;
}

.bot-card-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
}

.bot-stat-label {
  opacity: 0.6;
  margin-right: 4px;
}

.bot-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bot-card-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bot-card-toolbar-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.bot-card-toolbar-sep {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0 2px;
}

.bots-stopped-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}

.bots-stopped-banner-text {
  flex: 1 1 240px;
  line-height: 1.45;
}

.modules-toolbar-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

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

.modules-toolbar-hint {
  font-size: 0.85rem;
  flex: 1 1 200px;
}

.dashboard-readonly .modules-toolbar,
.dashboard-readonly .btn-bot-start,
.dashboard-readonly .btn-bot-stop,
.dashboard-readonly .btn-bot-dry,
.dashboard-readonly .btn-bot-real,
.dashboard-readonly .btn-bot-config,
.dashboard-readonly .bot-mode-toggle,
.dashboard-readonly .bot-card-toolbar-sep,
.dashboard-readonly #settings-save,
.dashboard-readonly #config-advise-run {
  display: none !important;
}

.bot-mode-toggle {
  display: inline-flex;
  vertical-align: middle;
}

.bot-mode-toggle .btn {
  min-width: 54px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.35;
}

.bot-mode-toggle .btn:focus {
  box-shadow: none;
}

.bot-mode-toggle .btn-outline-carolina,
.bot-mode-toggle .btn-outline-danger {
  background: rgba(255, 255, 255, 0.03);
}

.bot-mode-toggle .btn-outline-carolina:hover,
.bot-mode-toggle .btn-outline-danger:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Activity table (Polymarket-style) */
.activity-section {
  margin-top: 1rem;
}

.activity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.activity-tab {
  padding: 6px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: inherit;
  font-size: 0.78rem;
  line-height: 1.25;
  cursor: pointer;
  opacity: 0.7;
  white-space: normal;
  text-align: left;
}

.activity-tab.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(91, 192, 222, 0.5);
}

.activity-table-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.activity-table thead th {
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  opacity: 0.55;
  font-weight: 500;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.activity-table tbody tr {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.activity-table tbody tr:last-child {
  border-bottom: none;
}

.activity-table td {
  padding: 12px 14px;
  vertical-align: middle;
}

.activity-type {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.activity-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
}

.activity-icon.buy { color: #28a745; border-color: rgba(40, 167, 69, 0.5); }
.activity-icon.sell { color: inherit; }
.activity-icon.position { color: #5bc0de; border-color: rgba(91, 192, 222, 0.5); }

.activity-market {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.activity-market-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.asset-icon-link {
  flex-shrink: 0;
  text-decoration: none;
}

.asset-icon-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.asset-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.asset-icon-fallback {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.asset-icon-fallback.btc { background: #f7931a; }
.asset-icon-fallback.eth { background: #627eea; }
.asset-icon-fallback.sol { background: #9945ff; }
.asset-icon-fallback.xrp { background: #23292f; }
.asset-icon-fallback.doge { background: #c2a633; }
.asset-icon-fallback.crypto { background: #555; }

.market-title {
  font-weight: 500;
  font-size: 13px;
  line-height: 21px;
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-title-link {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
  transition: color 0.15s ease;
}

.market-title-link:hover,
.market-title-link:focus {
  color: #5bc0de;
  text-decoration: underline;
}

.market-legs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.market-legs-inline {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}

.leg-inline-gap {
  display: inline-block;
  width: 10px;
  flex-shrink: 0;
}

.market-leg-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.leg-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
}

.leg-badge-up {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.leg-badge-down {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.leg-shares {
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: 0.15px;
  opacity: 0.55;
  white-space: nowrap;
}

.window-countdown {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
}

.window-countdown-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 26px;
}

.window-countdown-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: #f05a4f;
  font-variant-numeric: tabular-nums;
}

.window-countdown-expired .window-countdown-num {
  color: rgba(255, 255, 255, 0.35);
}

.window-countdown-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 3px;
}

.activity-value {
  font-weight: 600;
  white-space: nowrap;
}

.activity-value.positive { color: #28a745; }
.activity-value.negative { color: inherit; opacity: 0.9; }

.activity-time {
  opacity: 0.55;
  font-size: 0.8rem;
  white-space: nowrap;
}

.activity-empty {
  padding: 24px;
  text-align: center;
  opacity: 0.5;
  font-size: 0.85rem;
}

.dry-tag {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(91, 192, 222, 0.2);
  color: #5bc0de;
  margin-left: 6px;
  vertical-align: middle;
}

/* Dashboard modals (log, settings) */
.dash-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.dash-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.dash-modal-dialog {
  position: relative;
  width: min(980px, 96vw);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  animation: dash-popup-in 0.18s ease-out;
}

.dash-modal-dialog-wide {
  width: min(1120px, 96vw);
  max-height: min(90vh, 860px);
}

@keyframes dash-popup-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dash-modal-panel {
  width: 100%;
  max-height: inherit;
  background: var(--sidebar-bg, #1a1d24);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.dash-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.dash-modal-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.dash-modal-subtitle {
  font-size: 0.78rem;
  opacity: 0.6;
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}

.dash-modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  min-height: 200px;
}

.settings-modal-body {
  padding: 16px 20px 20px;
}

.settings-modal-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

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

.settings-modal-main .list-group-item {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.06);
}

.settings-modal-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-modal-side .card {
  background: rgba(255, 255, 255, 0.02);
}

.execution-health-pre {
  font-size: 0.78rem;
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.45;
}

/* Log popup table */
  margin: 0;
}

.log-modal-table {
  margin: 0;
  font-size: 0.82rem;
}

.log-modal-table thead th {
  position: sticky;
  top: 0;
  background: var(--sidebar-bg, #1a1d24);
  z-index: 1;
  white-space: nowrap;
}

.log-modal-table tbody td {
  vertical-align: middle;
}

.log-modal-table .opp-ok-yes {
  color: #28a745;
  font-weight: 600;
}

.log-modal-table .opp-ok-no {
  opacity: 0.55;
}

.log-modal-empty-state {
  padding: 32px 20px;
}

@media (max-width: 768px) {
  .analytics-kpi-card .card-body {
    flex-direction: column;
    align-items: flex-start;
  }
  .analytics-module-metrics {
    grid-template-columns: 1fr 1fr;
  }
}

/* Analytics dashboard (siQtheme-style widgets) */
.analytics-updated {
  font-size: 0.75rem;
  opacity: 0.5;
  margin-bottom: 1rem;
}

.analytics-kpi-card {
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.analytics-kpi-card .card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 1.1rem 1.25rem;
}

.analytics-kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  color: #fff;
}

.analytics-kpi-icon.bg-carolina { background: linear-gradient(135deg, #57a0d2, #3d8fc4); }
.analytics-kpi-icon.bg-success { background: linear-gradient(135deg, #28a745, #20903a); }
.analytics-kpi-icon.bg-warning { background: linear-gradient(135deg, #ffc107, #e0a800); color: #1a1d24; }
.analytics-kpi-icon.bg-danger { background: linear-gradient(135deg, #e84a67, #c82333); }

.analytics-kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
  margin: 0 0 4px;
  font-weight: 500;
}

.analytics-kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
}

.analytics-kpi-meta {
  font-size: 0.78rem;
  opacity: 0.55;
  margin-top: 2px;
}

.analytics-kpi-footer {
  padding: 0 1.25rem 1rem;
}

.analytics-kpi-footer .progress {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
}

.analytics-kpi-footer-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  opacity: 0.55;
  margin-bottom: 6px;
}

.analytics-module-card {
  margin-bottom: 1.25rem;
  height: calc(100% - 1.25rem);
}

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

.analytics-module-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.analytics-module-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}

.analytics-module-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.analytics-module-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.analytics-module-id {
  font-size: 0.68rem;
  opacity: 0.5;
  font-family: ui-monospace, monospace;
}

.analytics-module-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.analytics-metric {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.analytics-metric-value {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.analytics-metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
  margin-top: 2px;
}

.analytics-bar-row {
  margin-bottom: 10px;
}

.analytics-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.analytics-bar-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease;
}

.analytics-bar-fill.carolina { background: #57a0d2; }
.analytics-bar-fill.success { background: #28a745; }
.analytics-bar-fill.danger { background: #e84a67; }
.analytics-bar-fill.warning { background: #ffc107; }

.analytics-compare-table th,
.analytics-compare-table td {
  font-size: 0.82rem;
  vertical-align: middle;
}

.analytics-compare-table .asset-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-compare-table .asset-cell img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.analytics-note {
  font-size: 0.82rem;
  opacity: 0.72;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(87, 160, 210, 0.08);
  border: 1px solid rgba(87, 160, 210, 0.18);
}

.analytics-note i {
  color: #57a0d2;
  margin-right: 6px;
}

.analytics-profit-positive { color: #28a745; font-weight: 600; }
.analytics-profit-negative { color: #e84a67; font-weight: 600; }

@media (max-width: 768px) {
  .activity-table thead { display: none; }
  .activity-table tbody tr {
    display: block;
    margin-bottom: 8px;
    border-radius: 8px;
  }
  .activity-table td {
    display: block;
    padding: 6px 14px;
  }
  .activity-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 2px;
  }
}

.login-page {
  min-height: 100vh;
  background: #0f1419;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand .logo {
  font-size: 1.5rem;
  font-weight: 600;
}

.login-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.login-form .form-group {
  margin-bottom: 1rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.85;
}

.login-error {
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
