*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  min-height:100%;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:#f5f7fb;
  color:#111827;
}

button,
textarea{
  font:inherit;
}

button{
  cursor:pointer;
}

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

.sidebar{
  width:260px;
  background:#101522;
  color:#fff;
  padding:26px 18px;
  display:flex;
  flex-direction:column;
  position:fixed;
  inset:0 auto 0 0;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:0 8px 28px;
}

.brand-mark{
  width:42px;
  height:42px;
  border-radius:13px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:21px;
  background:#fff;
  color:#111827;
}

.brand strong{
  display:block;
  font-size:18px;
}

.brand span{
  display:block;
  margin-top:3px;
  font-size:12px;
  color:#9ca3af;
}

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

.nav-item{
  width:100%;
  border:0;
  background:transparent;
  color:#aeb6c7;
  padding:13px 14px;
  border-radius:12px;
  text-align:left;
  display:flex;
  align-items:center;
  gap:11px;
  transition:.2s;
}

.nav-item:hover,
.nav-item.active{
  color:#fff;
  background:#1d2433;
}

.nav-item .badge{
  margin-left:auto;
}

.badge{
  min-width:22px;
  height:22px;
  border-radius:11px;
  padding:0 7px;
  background:#fff;
  color:#111827;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
}

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

.back{
  display:block;
  color:#9ca3af;
  text-decoration:none;
  padding:12px;
}

.main{
  width:calc(100% - 260px);
  margin-left:260px;
  min-height:100vh;
}

.topbar{
  min-height:92px;
  background:#fff;
  border-bottom:1px solid #e5e7eb;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:18px 34px;
}

.topbar h1{
  margin:0;
  font-size:24px;
}

.topbar p{
  margin:5px 0 0;
  color:#6b7280;
}

.ai-status{
  display:flex;
  gap:10px;
  align-items:center;
  padding:9px 13px;
  border:1px solid #e5e7eb;
  border-radius:14px;
}

.ai-status strong,
.ai-status small{
  display:block;
}

.ai-status small{
  color:#6b7280;
  margin-top:2px;
}

.status-dot{
  width:10px;
  height:10px;
  border-radius:50%;
  background:#22c55e;
  box-shadow:
    0 0 0 5px rgba(34,197,94,.12);
}

.view{
  display:none;
  padding:28px 34px;
}

.view.active{
  display:block;
}

.stats{
  display:grid;
  grid-template-columns:
    repeat(4,minmax(0,1fr));
  gap:16px;
  margin-bottom:20px;
}

.stats article{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  padding:18px;
}

.stats span{
  color:#6b7280;
  font-size:13px;
}

.stats strong{
  margin-top:7px;
  display:block;
  font-size:27px;
}

.chat-layout{
  display:grid;
  grid-template-columns:
    minmax(0,1fr) 320px;
  gap:18px;
}

.chat-card,
.debug-card,
.panel{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:18px;
}

.chat-card{
  min-height:650px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.chat-head{
  padding:17px 20px;
  border-bottom:1px solid #e5e7eb;
  display:flex;
  align-items:center;
  gap:12px;
}

.avatar{
  width:42px;
  height:42px;
  border-radius:13px;
  background:#111827;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
}

.chat-head strong,
.chat-head span{
  display:block;
}

.chat-head span{
  color:#6b7280;
  font-size:12px;
  margin-top:3px;
}

.messages{
  flex:1;
  padding:22px;
  overflow:auto;
  max-height:470px;
}

.message{
  display:flex;
  margin-bottom:15px;
}

.message.user{
  justify-content:flex-end;
}

.bubble{
  max-width:78%;
  padding:13px 15px;
  border-radius:16px;
  line-height:1.5;
  background:#f1f5f9;
}

.message.user .bubble{
  background:#111827;
  color:#fff;
  border-bottom-right-radius:5px;
}

.message.ai .bubble{
  border-bottom-left-radius:5px;
}

.suggestions{
  display:flex;
  gap:8px;
  overflow:auto;
  padding:10px 18px;
  border-top:1px solid #edf0f3;
}

.suggestions button{
  border:1px solid #d9dee6;
  background:#fff;
  white-space:nowrap;
  border-radius:999px;
  padding:9px 12px;
  font-size:12px;
}

.composer{
  padding:14px 18px 18px;
  display:flex;
  gap:10px;
}

.composer textarea{
  resize:none;
  flex:1;
  border:1px solid #d7dce4;
  border-radius:14px;
  padding:13px 14px;
  outline:0;
}

.composer textarea:focus{
  border-color:#111827;
}

.composer button{
  border:0;
  background:#111827;
  color:#fff;
  padding:0 20px;
  border-radius:14px;
  font-weight:700;
}

.debug-card{
  padding:19px;
  min-width:0;
}

.section-title{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:#9ca3af;
  margin-bottom:8px;
}

.tool-name{
  padding:13px;
  background:#f8fafc;
  border-radius:11px;
  font-weight:700;
  margin-bottom:22px;
}

pre{
  max-width:100%;
  min-height:390px;
  overflow:auto;
  white-space:pre-wrap;
  word-break:break-word;
  background:#101522;
  color:#e5e7eb;
  border-radius:12px;
  padding:14px;
  font-size:11px;
  line-height:1.5;
}

.panel{
  padding:22px;
}

.panel-header{
  display:flex;
  justify-content:space-between;
  gap:20px;
  align-items:flex-start;
  margin-bottom:20px;
}

.panel h2{
  margin:0;
}

.panel p{
  color:#6b7280;
  margin:6px 0 0;
}

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

.list-item{
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:15px;
}

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

.list-item h3{
  font-size:15px;
  margin:0;
}

.list-item p{
  font-size:13px;
}

.meta{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:10px;
}

.chip{
  display:inline-flex;
  padding:5px 8px;
  border-radius:999px;
  background:#f1f5f9;
  font-size:11px;
}

.actions{
  display:flex;
  gap:7px;
}

.primary,
.secondary,
.danger{
  border:0;
  border-radius:10px;
  padding:9px 12px;
  font-weight:700;
}

.primary{
  background:#111827;
  color:#fff;
}

.secondary{
  background:#eef2f7;
  color:#111827;
}

.danger{
  background:#fee2e2;
  color:#991b1b;
}

.switch-row{
  display:flex;
  gap:18px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:14px;
}

.switch-row label{
  font-size:12px;
  color:#4b5563;
}

.switch-row input{
  vertical-align:middle;
  margin-right:5px;
}

.empty{
  padding:40px;
  text-align:center;
  color:#9ca3af;
  border:1px dashed #d1d5db;
  border-radius:14px;
}

.toast{
  position:fixed;
  right:22px;
  bottom:22px;
  padding:12px 16px;
  background:#111827;
  color:#fff;
  border-radius:12px;
  opacity:0;
  transform:translateY(10px);
  pointer-events:none;
  transition:.2s;
}

.toast.show{
  opacity:1;
  transform:none;
}

@media(max-width:1000px){

  .sidebar{
    width:78px;
    padding-left:10px;
    padding-right:10px;
  }

  .brand > div:last-child,
  .nav-item:not(.active) .badge,
  .nav-item{
    font-size:0;
  }

  .brand{
    justify-content:center;
  }

  .nav-item{
    justify-content:center;
  }

  .nav-item span{
    font-size:18px;
  }

  .main{
    width:calc(100% - 78px);
    margin-left:78px;
  }

  .chat-layout{
    grid-template-columns:1fr;
  }

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

}

@media(max-width:640px){

  .sidebar{
    display:none;
  }

  .main{
    width:100%;
    margin:0;
  }

  .topbar{
    padding:15px;
  }

  .view{
    padding:14px;
  }

  .stats{
    grid-template-columns:1fr 1fr;
    gap:8px;
  }

  .stats article{
    padding:13px;
  }

  .chat-card{
    min-height:70vh;
  }

  .debug-card{
    display:none;
  }

  .bubble{
    max-width:90%;
  }

}
