:root{
  --bg:#070b13;
  --panel:#0b1220;
  --border:rgba(255,255,255,.10);
  --muted:rgba(255,255,255,.66);
  --text:rgba(255,255,255,.92);
  --primary:#3b82f6;
  --primary2:#22c55e;
  --shadow: 0 12px 36px rgba(0,0,0,.55);
  --radius:14px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "PingFang SC","Microsoft YaHei", Arial, sans-serif;
  background: radial-gradient(1200px 800px at 15% 0%, rgba(59,130,246,.22), transparent 60%),
              radial-gradient(900px 700px at 85% 20%, rgba(34,197,94,.16), transparent 55%),
              var(--bg);
  color:var(--text);
}
.hidden{display:none !important}
.h1{font-size:18px;font-weight:700}
.muted{color:var(--muted);font-size:12px}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.divider{height:1px;background:var(--border);margin:12px 0}
.w100{width:100%}

.btn{
  appearance:none;border:1px solid var(--border);background:transparent;color:var(--text);
  padding:9px 12px;border-radius:12px;cursor:pointer;
  transition: transform .04s ease, background .15s ease, border-color .15s ease;
}
.btn:hover{background:rgba(255,255,255,.06)}
.btn:active{transform:translateY(1px)}
.btn.primary{background:linear-gradient(135deg,var(--primary),#60a5fa);border-color:transparent}
.btn.primary:hover{background:linear-gradient(135deg,#2563eb,#60a5fa)}
.btn.ghost{background:rgba(255,255,255,.03)}

.app{display:flex;height:100vh;max-height:100vh}
.sidebar{
  width:320px;min-width:280px;
  padding:16px;
  background:rgba(11,18,32,.84);
  border-right:1px solid var(--border);
  backdrop-filter: blur(10px);
  display:flex;flex-direction:column;gap:12px;
}
.brand{display:flex;gap:12px;align-items:center}
.logo{
  width:42px;height:42px;border-radius:14px;
  background:linear-gradient(135deg,var(--primary),var(--primary2));
  display:flex;align-items:center;justify-content:center;
  font-weight:800;
}
.brand .title{font-size:14px;font-weight:800}
.brand .sub{font-size:12px;color:var(--muted)}
.sidebar-actions{display:flex;gap:10px}
.sidebar-section{flex:1;overflow:auto}
.section-title{font-size:12px;color:var(--muted);margin:10px 0}
.session-list{display:flex;flex-direction:column;gap:8px}
.session-item{
  padding:10px 10px;border-radius:12px;border:1px solid var(--border);
  background:rgba(255,255,255,.03);cursor:pointer;
  display:flex;gap:10px;align-items:center;justify-content:space-between;
}
.session-item.active{border-color:rgba(59,130,246,.55);background:rgba(59,130,246,.10)}
.session-item .t{font-size:13px;max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.session-item .time{font-size:11px;color:var(--muted)}
.session-item .menu{display:flex;gap:6px}
.icon-btn{border:1px solid var(--border);background:transparent;border-radius:10px;color:var(--muted);cursor:pointer;padding:6px 8px}
.icon-btn:hover{background:rgba(255,255,255,.06);color:var(--text)}

.sidebar-footer{display:flex;flex-direction:column;gap:10px}
.status-pill{
  display:flex;align-items:center;gap:8px;
  border:1px solid var(--border);border-radius:999px;padding:8px 10px;
  background:rgba(255,255,255,.03);
}
.dot{width:9px;height:9px;border-radius:99px;background:rgba(239,68,68,.9)}
.dot.on{background:rgba(34,197,94,.95)}

.main{flex:1;display:flex;flex-direction:column}
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 16px;border-bottom:1px solid var(--border);
  background:rgba(11,18,32,.55);backdrop-filter: blur(10px);
}
.session-title{display:flex;flex-direction:column;gap:4px}
.content{display:flex;flex:1;min-height:0}
.chat{flex:1;display:flex;flex-direction:column;min-height:0}
.message-list{flex:1;overflow:auto;padding:16px;display:flex;flex-direction:column;gap:10px}
.msg{
  max-width:860px;width:fit-content;
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  border-radius:var(--radius);
  padding:10px 12px;
  white-space:pre-wrap;line-height:1.5;
  box-shadow: 0 8px 22px rgba(0,0,0,.25);
}
.msg.user{margin-left:auto;background:rgba(59,130,246,.10);border-color:rgba(59,130,246,.35)}
.msg.assistant{margin-right:auto;background:rgba(34,197,94,.07);border-color:rgba(34,197,94,.26)}
.msg .meta{margin-top:6px;font-size:11px;color:var(--muted)}
.msg .attach{display:flex;gap:10px;align-items:center;margin-top:8px;flex-wrap:wrap}
.pill{
  border:1px solid var(--border);border-radius:999px;padding:6px 10px;font-size:12px;color:var(--muted);
  background:rgba(0,0,0,.18);
}
.pill a{color:var(--text);text-decoration:none}

.composer{
  padding:12px 16px;border-top:1px solid var(--border);
  background:rgba(11,18,32,.55);backdrop-filter: blur(10px);
}
.composer-row{display:flex;gap:10px;align-items:flex-end}
textarea{
  flex:1;resize:none;min-height:40px;max-height:140px;
  border:1px solid var(--border);border-radius:14px;
  background:rgba(255,255,255,.03);color:var(--text);
  padding:10px 12px;outline:none;
}
textarea:focus{border-color:rgba(59,130,246,.55)}
.attachments{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.attachment{
  border:1px dashed rgba(255,255,255,.22);border-radius:12px;padding:8px 10px;
  font-size:12px;color:var(--muted);display:flex;gap:10px;align-items:center;
}
.attachment img{width:44px;height:44px;border-radius:10px;object-fit:cover;border:1px solid var(--border)}

.insights{
  width:340px;border-left:1px solid var(--border);
  background:rgba(11,18,32,.70);backdrop-filter: blur(10px);
  padding:16px;overflow:auto
}
.card{
  border:1px solid var(--border);border-radius:var(--radius);
  background:rgba(255,255,255,.03);
  padding:14px;box-shadow:var(--shadow);
}
.card-title{font-weight:800;margin-bottom:8px}
.big{font-size:18px;font-weight:900}
.sub{font-size:12px;color:var(--muted);font-weight:600}
.bar-grid{display:flex;flex-direction:column;gap:8px;margin-top:10px}
.bar{
  display:grid;grid-template-columns: 74px 1fr 40px;gap:10px;align-items:center;
}
.bar .label{font-size:12px;color:var(--muted)}
.bar .track{height:10px;background:rgba(255,255,255,.06);border:1px solid var(--border);border-radius:99px;overflow:hidden}
.bar .fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--primary2))}
.bar .val{font-size:12px;color:var(--muted);text-align:right}

.modal{position:fixed;inset:0;z-index:50;display:flex;align-items:center;justify-content:center}
.modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.62)}
.modal-body{position:relative;width:min(980px,92vw);max-height:86vh;overflow:hidden;border-radius:18px;border:1px solid var(--border);background:rgba(11,18,32,.92);backdrop-filter: blur(12px);box-shadow:var(--shadow)}
.modal-header{display:flex;justify-content:space-between;align-items:center;padding:12px 14px;border-bottom:1px solid var(--border)}
.modal-title{font-weight:900}
.modal-content{padding:14px;overflow:auto;max-height:74vh}

.admin{padding:16px}
.admin-topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.admin-grid{display:grid;grid-template-columns: 1fr 1fr;gap:14px}
.list{display:flex;flex-direction:column;gap:8px;margin-top:10px;max-height:520px;overflow:auto}
.list-item{
  border:1px solid var(--border);border-radius:14px;padding:10px 12px;background:rgba(255,255,255,.03);
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
}
.list-item .title{font-weight:800}
.list-item .desc{font-size:12px;color:var(--muted);white-space:pre-wrap}
.tag{font-size:11px;color:rgba(255,255,255,.74);border:1px solid var(--border);border-radius:999px;padding:4px 8px;background:rgba(0,0,0,.18)}
.form{display:flex;flex-direction:column;gap:10px;margin-top:10px}
.form-row{display:grid;grid-template-columns: 130px 1fr;gap:10px;align-items:center}
input,select{
  border:1px solid var(--border);border-radius:12px;background:rgba(255,255,255,.03);
  padding:9px 10px;color:var(--text);outline:none
}
input:focus,select:focus{border-color:rgba(59,130,246,.55)}

@media (max-width: 980px){
  .sidebar{width:280px}
  .insights{display:none}
  .admin-grid{grid-template-columns: 1fr}
}

