@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0e17;
  --bg-surface: #0f1520;
  --bg-card: #141b2d;
  --bg-card-hover: #1a2340;
  --bg-card-elevated: #192038;
  --border: #1e2a3a;
  --border-light: #2a3a52;
  --text: #e8ecf4;
  --text-muted: #6b7a94;
  --text-secondary: #8d9bb5;
  --green: #2dd4a8;
  --green-dim: #1a9e7a;
  --green-bg: rgba(45, 212, 168, 0.1);
  --green-glow: rgba(45, 212, 168, 0.15);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.1);
  --blue: #58a6ff;
  --blue-bg: rgba(88, 166, 255, 0.1);
  --amber: #f0b429;
  --amber-bg: rgba(240, 180, 41, 0.1);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.1);
  --teal: #2dd4bf;
  --teal-bg: rgba(45, 212, 191, 0.1);
  --sidebar-w: 72px;
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.mono {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}
.profit {
  color: var(--green) !important;
}
.loss {
  color: var(--red) !important;
}

/* ── App Layout ──────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  margin-bottom: 32px;
}

.sidebar-logo .logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: contain;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-link {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-link:hover {
  background: var(--bg-card);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--teal-bg);
  color: var(--teal);
  box-shadow: 0 0 20px rgba(45, 212, 191, 0.08);
}

.sidebar-bottom {
  margin-top: auto;
}

.status-indicator {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main Content ────────────────────────── */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ── Top Bar ─────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
}

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

.topbar-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 12px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.mobile-logo {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: contain;
}

@media (max-width: 900px) {
  .mobile-logo {
    display: block;
  }
}

/* ── Summary Cards ───────────────────────── */

.summary-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.25s;
}

.summary-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.summary-card:hover::before {
  background: var(--teal);
}

.summary-card-info-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0;
  transition:
    opacity 0.2s ease,
    color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
}

.summary-card:hover .summary-card-info-btn {
  opacity: 1;
}

.summary-card-info-btn:hover {
  color: var(--teal);
}

.summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--purple-bg);
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-icon--teal {
  background: var(--teal-bg);
  color: var(--teal);
}

.summary-icon--green {
  background: var(--green-bg);
  color: var(--green);
}

.summary-icon--amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.summary-icon--blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.summary-icon--purple {
  background: var(--purple-bg);
  color: var(--purple);
}

.summary-info {
  min-width: 0;
}

.summary-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-value.small {
  font-size: 1rem;
}

/* ── Panel ───────────────────────────────── */

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color 0.2s;
}

.panel:hover {
  border-color: var(--border-light);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.panel-header h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
}

/* ── Coin Cards Grid ──────────────────────── */

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

.coin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.25s ease;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.coin-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(45, 212, 191, 0.06),
    transparent 70%
  );
}

.coin-card:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(45, 212, 191, 0.08);
}

.coin-card:hover::after {
  opacity: 1;
}

.coin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.coin-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.coin-symbol {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.coin-price {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.coin-change {
  font-size: 0.8rem;
  font-weight: 600;
}

.coin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.coin-stat-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.coin-stat-value {
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Overall Performance ─────────────────── */

.overall-perf {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}

.overall-perf .perf-item {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

/* ── Mode Buttons & Controls ─────────────── */

.mode-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--bg-card-hover);
  transform: scale(1.08);
}

.btn-start.active {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 16px var(--green-glow);
}

.btn:focus {
  outline: none;
}
.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.btn-stop:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(248, 81, 73, 0.25);
  border-color: var(--red);
  transform: scale(1.08);
}

/* ── Grid Layout ─────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── Bot Section ─────────────────────────── */

.bot-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-pnl {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Status ──────────────────────────────── */

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

.status-dot.running {
  background: var(--green);
  box-shadow: 0 0 12px var(--green-glow);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Positions ───────────────────────────── */

.positions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.position-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.position-item:hover {
  border-color: var(--border-light);
  background: var(--bg-card-elevated);
}

.position-symbol {
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 56px;
}

.position-details {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.position-info {
  color: var(--text-muted);
}

.close-pos-btn {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.5rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  opacity: 0.45;
  transition: all 0.2s;
}

.close-pos-btn:hover {
  background: var(--red);
  color: #fff;
  opacity: 1;
  transform: scale(1.08);
}

.close-pos-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.copy-trade-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.15rem;
  padding: 2px 6px;
  opacity: 0.45;
  transition: all 0.2s;
  border-radius: 6px;
}

.copy-trade-btn:hover {
  opacity: 1;
  color: var(--teal);
  background: var(--teal-bg);
}

.close-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid transparent;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Performance ─────────────────────────── */

.perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.perf-item {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.perf-item:hover {
  border-color: var(--border-light);
}

.perf-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.perf-value {
  font-size: 1.15rem;
  font-weight: 600;
}

/* ── Table ────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 500px;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-card-elevated);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tag-crypto-agg {
  background: var(--purple-bg);
  color: var(--purple);
}

.tag-crypto-con {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
}

.tag-reason {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

/* ── Confirm Modal ────────────────────────── */

.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1100;
  justify-content: center;
  align-items: center;
}

.confirm-overlay.open {
  display: flex;
}

.confirm-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(90vw, 380px);
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.confirm-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.confirm-body {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.confirm-btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.confirm-btn.cancel {
  background: transparent;
  color: var(--text-muted);
}

.confirm-btn.cancel:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.confirm-btn.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.confirm-btn.danger:hover {
  opacity: 0.85;
}

/* ── Log ──────────────────────────────────── */

.log-output {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 0.75rem;
  line-height: 1.65;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 600px;
  overflow-y: auto;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.log-output::-webkit-scrollbar {
  width: 6px;
}
.log-output::-webkit-scrollbar-track {
  background: transparent;
}
.log-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.btn-sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-sm:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--bg-card-hover);
  transform: scale(1.08);
}

.empty {
  color: var(--text-muted);
  font-size: 0.825rem;
  text-align: center;
  padding: 20px 0;
}

/* ── Portrait lock overlay ─────────────── */

.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.rotate-overlay .rotate-icon {
  font-size: 3rem;
}
.rotate-overlay .rotate-text {
  font-size: 1.1rem;
  color: var(--text-muted);
}

@media only screen and (max-width: 768px) and (orientation: landscape) {
  .rotate-overlay {
    display: flex;
  }
}

/* ── Responsive ──────────────────────────── */

@media (max-width: 1200px) {
  .summary-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
    gap: 14px;
    max-width: 100vw;
  }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    order: 2;
  }
  .topbar-title {
    font-size: 1.15rem;
  }
  .topbar-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    order: 1;
  }
  .mobile-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .mode-buttons {
    display: flex;
    gap: 8px;
  }
  .btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 0.8rem;
  }
  .btn-label {
    display: none;
  }
  .summary-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .summary-card {
    padding: 14px;
  }
  .summary-value {
    font-size: 1rem;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .overall-perf {
    grid-template-columns: repeat(3, 1fr);
  }
  .panel {
    padding: 14px;
    border-radius: 12px;
  }
  .position-item {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
  }
  .position-details {
    flex: 1;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
  }
  .perf-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .perf-item {
    padding: 12px;
  }
  .perf-value {
    font-size: 1rem;
  }
  table {
    font-size: 0.75rem;
  }
  th,
  td {
    padding: 8px 8px;
  }
  .log-output {
    font-size: 0.68rem;
    line-height: 1.55;
    max-height: 550px;
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 10px;
    gap: 10px;
  }
  .topbar-title {
    font-size: 1.2rem;
  }
  .summary-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .summary-card {
    padding: 12px;
    gap: 10px;
  }
  .summary-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .summary-icon svg {
    width: 18px;
    height: 18px;
  }
  .summary-value {
    font-size: 0.9rem;
  }
  .summary-label {
    font-size: 0.6rem;
  }
  .overall-perf {
    grid-template-columns: 1fr 1fr;
  }
  .coins-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .coins-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .mode-buttons {
    gap: 12px;
  }
  .btn {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }
  .panel {
    border-radius: 10px;
    padding: 12px;
  }
  .panel-header h2 {
    font-size: 0.78rem;
  }
  .position-symbol {
    font-size: 0.85rem;
  }
  .position-details {
    font-size: 0.72rem;
  }
  .perf-grid {
    gap: 8px;
  }
  .perf-item {
    padding: 10px;
  }
  .perf-label {
    font-size: 0.62rem;
  }
  .perf-value {
    font-size: 0.9rem;
  }
  .log-output {
    font-size: 0.62rem;
    max-height: 450px;
  }
  th,
  td {
    padding: 6px 6px;
    font-size: 0.7rem;
  }
  .tag {
    font-size: 0.6rem;
    padding: 2px 5px;
  }
}

/* ── Pagination ──────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 0 4px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.page-btn:hover:not(.disabled):not(.active) {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--bg-card-hover);
}

.page-btn.active {
  background: var(--teal-bg);
  border-color: var(--teal);
  color: var(--teal);
}

.page-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-dots {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0 4px;
}

/* ── Bottom Nav (mobile) ──────────────────── */

.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 10px 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: center;
  }
  .bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    padding: 6px 12px;
    border-radius: 10px;
    transition: all 0.2s;
  }
  .bottom-nav-link.active {
    color: var(--teal);
  }
  .bottom-nav-link:active {
    background: var(--bg-card);
  }
  .main-content {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Charts Page Grid ────────────────────── */

.charts-tf-bar {
  display: flex;
  gap: 4px;
}

.charts-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.charts-grid .chart-panel:last-child:nth-child(odd) {
  grid-column: auto;
}

.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.chart-panel:hover {
  border-color: var(--border-light);
}

.chart-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.chart-panel-symbol {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-panel-name {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.chart-panel-price {
  font-size: 1.05rem;
  font-weight: 600;
}

.chart-panel-body {
  position: relative;
  height: 310px;
  padding: 6px 6px 6px 6px;
  overflow: visible;
}

.chart-panel-body canvas {
  display: block;
}

.chart-panel-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .charts-grid .chart-panel:last-child:nth-child(odd) {
    grid-column: auto;
  }
  .chart-panel-body {
    height: 220px;
  }
  .charts-tf-bar {
    flex-wrap: wrap;
  }
}

/* ── AI Decisions Panel ─────────────────────── */

.ai-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ai-status-badge.ai-on {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-dim);
}

.ai-status-badge.ai-off {
  background: rgba(107, 122, 148, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.ai-status-badge.ai-no-credits {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
  animation: pulse-red 2s ease-in-out infinite;
}

@keyframes pulse-red {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.ai-credit-alert {
  padding: 10px 16px;
  background: var(--red-bg);
  border-bottom: 1px solid var(--red);
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
}

.ai-stats {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.ai-stat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ai-stat strong {
  color: var(--text);
}

#aiDecisionsTable th,
#aiDecisionsTable td {
  font-size: 0.8rem;
  padding: 8px 10px;
}

.ai-confirm {
  color: var(--green);
  font-weight: 600;
}

.ai-reject {
  color: var(--red);
  font-weight: 600;
}

.ai-wait {
  color: var(--yellow, #f0c040);
  font-weight: 600;
}

.ai-action-icon {
  font-size: 0.9em;
  margin-right: 2px;
}

.ai-type-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0.9;
}

.ai-reasoning {
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* ── AI Decision Modal ────────────────────── */

.ai-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1200;
  justify-content: center;
  align-items: center;
}

.ai-modal-overlay.open {
  display: flex;
}

.ai-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(92vw, 440px);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.ai-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-modal-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.ai-modal-close:hover {
  color: var(--text-primary);
}

.ai-modal-meta {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.ai-modal-meta strong {
  color: var(--text-primary);
}

.ai-modal-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow-y: auto;
}

.conf-high {
  color: var(--green);
}

.conf-med {
  color: var(--yellow, #f0c040);
}

.conf-low {
  color: var(--text-muted);
}
