/* White UI */
:root{
  --bg:#ffffff;
  --panel:#ffffff;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.04);

  --ready-bg:#dcfce7;  --ready-fg:#166534;
  --pending-bg:#fef9c3;--pending-fg:#854d0e;
  --failed-bg:#fee2e2; --failed-fg:#991b1b;

  --user-bubble:#0b5fff;
  --assistant-bubble:#f1f5f9;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
}

.h1{ font-size:22px; margin:0; }
.h2{ font-size:16px; font-weight:700; }
.kpi{ font-size:28px; font-weight:800; margin-top:6px; }
.muted{ color: var(--muted); font-size:12px; }
.row{ display:flex; }
.col{ display:flex; flex-direction:column; }
.grid3{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:12px;
}
@media (max-width: 920px){
  .grid3{ grid-template-columns: 1fr; }
}

.btn{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-weight: 600;
}
.btn.primary{
  background: #0b5fff;
  color: #fff;
  border-color: #0b5fff;
}
.input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
}

.card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.tags{ display:flex; gap:8px; flex-wrap:wrap; }
.tag{
  border:1px solid var(--border);
  background:#fff;
  border-radius:999px;
  padding:4px 8px;
  font-size:12px;
  color: var(--muted);
}

/* Layout */
.layout{
  display:flex;
  height:100vh;
}

/* Sidebar */
.sidebar{
  width: 330px;
  min-width: 280px;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display:flex;
  flex-direction:column;
}
.sidebar-head{
  padding: 14px 14px 10px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-titleRow{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.sidebar-title{
  font-size:14px;
  margin:0;
  font-weight:800;
}
.sidebar-subtitle{
  margin-top:6px;
  font-size:12px;
  color: var(--muted);
}
.sidebar-list{
  padding: 10px;
  overflow:auto;
}
.docItem{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background:#fff;
  box-shadow: var(--shadow);
  cursor:pointer;
  margin-bottom:10px;
  display:flex;
  gap:10px;
  align-items:flex-start;
}
.docItem.active{
  outline: 2px solid rgba(11,95,255,.25);
  border-color: rgba(11,95,255,.35);
}
.docIcon{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:11px;
  color: var(--muted);
  background: #fff;
  flex: 0 0 auto;
}
.docMeta{ flex: 1 1 auto; min-width:0; }
.docName{
  font-size:13px;
  font-weight:800;
  margin:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.docSummary{
  font-size:12px;
  color: var(--muted);
  margin-top:4px;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient: vertical;
  overflow:hidden;
}
.docSubRow{
  margin-top:8px;
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:space-between;
}
.docDate{
  font-size:11px;
  color: var(--muted);
  white-space:nowrap;
}

.status-box{
  font-size:11px;
  font-weight:800;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space:nowrap;
}
.status-box.ready{ background: var(--ready-bg); color: var(--ready-fg); border-color: rgba(22,101,52,.25); }
.status-box.pending{ background: var(--pending-bg); color: var(--pending-fg); border-color: rgba(133,77,14,.25); }
.status-box.failed{ background: var(--failed-bg); color: var(--failed-fg); border-color: rgba(153,27,27,.25); }

/* Main */
.main{
  flex: 1 1 auto;
  overflow:auto;
}
.wrap{
  padding: 16px 18px;
  max-width: 1100px;
}

/* Chat window */
.chatWindow{
  margin-top:12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  height: 52vh;
  min-height: 320px;
  overflow: auto;
  padding: 12px;
}
.chatRow{
  display:flex;
  margin: 10px 0;
}
.chatRow.user{ justify-content:flex-end; }
.chatRow.assistant{ justify-content:flex-start; }

.bubble{
  max-width: 78%;
  border-radius: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.bubble.user{
  background: var(--user-bubble);
  color:#fff;
  border-color: rgba(11,95,255,.35);
}
.bubble.assistant{
  background: var(--assistant-bubble);
  color: var(--text);
}
.bubbleMeta{
  font-size:11px;
  margin-top:6px;
  opacity:.85;
}
.bubbleMeta span{ opacity:.85; }

.qaSeparator{
  border:0;
  border-top:1px solid var(--border);
  margin: 12px 0;
}

.chatComposer{
  margin-top: 12px;
  display:flex;
  gap:10px;
  align-items:center;
}
.chatInput{
  flex: 1 1 auto;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* History drawer */
.drawerBackdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.40);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.drawerBackdrop.open{
  opacity: 1;
  pointer-events: auto;
}
.drawer{
  position: fixed;
  top: 0; right: -420px;
  width: 420px;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;
  transition: right .25s ease;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.drawer.open{ right: 0; }
.drawerHead{
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.drawerList{
  overflow:auto;
  padding-right: 6px;
}
.drawerItem{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  cursor:pointer;
  background:#fff;
  box-shadow: var(--shadow);
}
.drawerItemTitle{ font-weight:800; font-size:13px; }
.drawerItemMeta{ color: var(--muted); font-size:12px; margin-top:4px; }
