:root{
  --bg: #f7f9fb;
  --panel: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --border: #e5e7eb;
  --shadow: 0 2px 6px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
  --gap: 26px;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}


.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 26px 36px;        
  min-height: 96px;          
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.brand{
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.6px;
}

.nav{
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.nav-link{
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  transition: color .15s ease;
}

.nav-link:hover{
  color: var(--text);
}

.sep{ opacity: 0.4; user-select: none; }

.meta{
  justify-self: end;
  display: grid;
  gap: 4px;
  text-align: right;
}

.meta-line{
  font-size: 13px;
  color: var(--muted);
}

.meta-val{
  color: var(--text);
  font-weight: 600;
}


.layout{
  display: grid;
  grid-template-columns: 70% 1fr;
  gap: var(--gap);
  padding: 32px 40px;
  align-items: start;
}


.chart-area{ 
  min-height: 80vh; 
}

.chart-placeholder{
  width: 100%;
  height: clamp(520px, 80vh, 900px); 
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
}

.chart-title{
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .2px;
}


.sidebar{
  
  position: sticky;
  top: 120px;                 
  display: flex;
  flex-direction: column;
  gap: 14px;

  
  max-height: calc(100vh - 140px);
  overflow: hidden;

  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.sidebar-title{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  letter-spacing: .2px;
}

.ai-card{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: var(--shadow);
}

.ai-card.empty{
  color: var(--muted);
  opacity: 0.8;
}


@media (max-width: 1100px){
  .layout{
    grid-template-columns: 1fr;
    padding: 24px;
  }
  .meta{ display: none; }
}

.models-list{
  display: grid;
  gap: 12px;
  flex: 0 0 auto;     
}

.model-card{
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.model-avatar{
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #f8fafc;           
  border: 3px solid #e2e8f0;      
}

.model-info{
  display: grid;
  gap: 6px;
}

.model-header{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.model-name{
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.model-pnl{
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.model-wallet{
  font-size: 12px;
  color: var(--muted);
}

.model-wallet a{
  color: var(--accent);
  text-decoration: none;
}
.model-wallet a:hover{
  text-decoration: underline;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    filter: drop-shadow(0 0 0 rgba(15,23,42,0));
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: drop-shadow(0 8px 24px rgba(15,23,42,0.12));
  }
}

.model-popover{
  
  animation: popIn .16s ease-out;
  will-change: transform, opacity, filter;
  transform-origin: top left;
}


@media (prefers-reduced-motion: reduce){
  .model-popover{
    animation: none !important;
  }
}

.trade-feed{
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;      
  overflow-y: auto;
  padding-right: 4px;
}
.trade-feed::-webkit-scrollbar{ width: 8px; }
.trade-feed::-webkit-scrollbar-track{ background: transparent; }
.trade-feed::-webkit-scrollbar-thumb{
  background: rgba(100,116,139,.25);
  border-radius: 8px;
}
.trade-feed:hover::-webkit-scrollbar-thumb{ background: rgba(100,116,139,.38); }


@media (max-width: 1100px){
  .layout{
    grid-template-columns: 1fr;
    padding: 24px;
  }
  .meta{ display: none; }

  .sidebar{
    position: static;
    max-height: none;
  }
  .trade-feed{
    max-height: 40vh; 
  }
}


.trade-item{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}


.trade-item.buy{  border-left: 4px solid #16a34a; } 
.trade-item.sell{ border-left: 4px solid #dc2626; } 


.trade-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.trade-title{
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .2px;
  color: var(--text);
}

.trade-title .model{ font-weight: 600; }
.trade-title .dash{ opacity: .6; margin: 0 6px; }
.trade-title .action.buy{ color: #16a34a; font-weight: 700; text-transform: uppercase; }
.trade-title .action.sell{ color: #dc2626; font-weight: 700; text-transform: uppercase; }
.trade-title .token{ color: var(--muted); }

.trade-time{
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}


.trade-body{
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 12px;
}

.trade-label{ color: var(--muted); }
.trade-val{
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.trade-val.positive{ color: #16a34a; }
.trade-val.negative{ color: #dc2626; }


.trade-foot{
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  display: flex; gap: 10px; flex-wrap: wrap;
}


.modal-backdrop{
  position: fixed; inset: 0;
  background: rgba(15,23,42,.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center; justify-content: center;
  z-index: 99999;
  animation: modalFade .12s ease-out;
}
@keyframes modalFade {
  from { opacity: 0 } to { opacity: 1 }
}
.modal{
  width: min(920px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr;
}
.modal-header{
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title{
  font-weight: 700; font-size: 15px;
  display: flex; gap: 10px; align-items: center;
}
.modal-title .dot{
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid transparent;
}
.modal-close{
  appearance: none; border: 0; background: transparent;
  font: inherit; font-weight: 700; color: var(--muted);
  cursor: pointer; padding: 6px 8px; border-radius: 8px;
}
.modal-close:hover{ background: #f3f4f6; color: var(--text); }

.modal-stats{
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: grid; gap: 10px;
}
.modal-stats-row{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.stat{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid; gap: 4px;
}
.stat .label{ font-size: 12px; color: var(--muted); }
.stat .val{ font-weight: 700; }
.stat .val.positive{ color:#16a34a }
.stat .val.negative{ color:#dc2626 }


.modal-chart{
  width: 100%;
  height: 250px;       
  overflow: hidden;    
}
.modal-chart canvas{
  display: block;
  width: 100%;
  height: 100%;        
}

.modal-table-wrap{
  padding: 12px 16px 16px;
}
.reasons-title{
  font-size: 13px; color: var(--muted); margin: 4px 0 10px;
}
.reasons-table{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}
.reasons-head{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.reasons-head div{ padding: 10px 12px; }

.reasons-body{
  max-height: 360px;         
  overflow: auto;
}
.reason-row{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.reason-row div{ padding: 10px 12px; }
.reason-row:nth-child(odd){ background: #fff; }
.reason-row:nth-child(even){ background: #fcfdff; }

.reasons-body::-webkit-scrollbar{ width: 8px; }
.reasons-body::-webkit-scrollbar-thumb{
  background: rgba(100,116,139,.25);
  border-radius: 8px;
}
.reasons-body:hover::-webkit-scrollbar-thumb{ background: rgba(100,116,139,.38); }


.modal-stats{
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;   
}


.modal-stats-row{
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
}


.modal-chart{
  flex: 1 1 auto;      
  min-height: 200px;   
  width: 100%;
  overflow: hidden;
}


.modal-chart canvas{
  display: block;
  width: 100%;
  height: 100%;
}

.modal{
  
  grid-template-rows: auto 1fr auto;   
}


.modal-stats{
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;   
}


.modal-chart{
  flex: 1 1 auto;    
  min-height: 200px; 
  height: auto;      
  width: 100%;
  overflow: hidden;
}


.modal-chart canvas{
  display: block;
  width: 100%;
  height: 100%;
}


.modal-table-wrap{
  max-height: 40vh;      
  overflow: auto;
}