:root {
  --accent: #4f46e5;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e5ea;
  --text: #1a1b1e;
  --muted: #6b7280;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
#app { min-height: 100vh; display: flex; flex-direction: column; }

.auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  background: var(--card); padding: 32px; border-radius: 12px; width: 340px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06); border: 1px solid var(--border);
}
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
button {
  cursor: pointer; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px;
  font-weight: 600; background: var(--accent); color: #fff;
}
button.secondary { background: #eef0f4; color: var(--text); }
button.danger { background: var(--danger); }
button:disabled { opacity: .55; cursor: default; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

.shell { display: flex; flex: 1; min-height: 100vh; }
.sidebar {
  width: 220px; background: #17181c; color: #d7d8dc; display: flex; flex-direction: column;
  padding: 18px 12px;
}
.sidebar .brand { font-weight: 700; font-size: 15px; color: #fff; padding: 0 8px 18px; }
.sidebar .brand small { display:block; font-weight: 400; color: #8b8d95; font-size: 11px; margin-top:2px;}
.sidebar nav a {
  display: block; padding: 9px 10px; border-radius: 8px; color: #d7d8dc; text-decoration: none;
  font-size: 14px; margin-bottom: 2px; cursor: pointer;
}
.sidebar nav a:hover, .sidebar nav a.active { background: #2a2c33; color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .who { font-size: 12px; color: #8b8d95; padding: 8px; }

.main { flex: 1; padding: 28px 32px; overflow-y: auto; }
.main h2 { margin-top: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.bot-card { cursor: pointer; }
.bot-card h3 { margin: 0 0 6px; font-size: 15px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef0f4; color: var(--muted); }
.badge.active { background: #dcfce7; color: #15803d; }
.badge.inactive { background: #fee2e2; color: #b91c1c; }
.muted { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { background: none; color: var(--muted); border-radius: 0; padding: 8px 14px; font-weight: 500; }
.tabs button.active { color: var(--accent); border-bottom: 2px solid var(--accent); }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.msg-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.msg { max-width: 70%; padding: 8px 12px; border-radius: 10px; font-size: 13px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: #eef0f4; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }

.history-split { display: flex; gap: 16px; align-items: flex-start; }
.history-list-col { flex: 0 0 340px; max-height: 75vh; overflow-y: auto; padding: 6px; }
.history-conv-col { flex: 1; min-width: 0; max-height: 75vh; overflow-y: auto; }
.conv-row {
  display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 4px; cursor: pointer; color: inherit;
}
.conv-row:hover { background: #f2f3f7; }
.conv-row.active { background: #eef0ff; border-color: var(--accent); }
.conv-row .conv-row-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.conv-row .conv-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stat-tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; min-width: 130px; }
.stat-tile-value { font-size: 22px; font-weight: 700; }
.stat-tile-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stats-bot-row:hover { background: #f2f3f7; cursor: pointer; }

.embed-box {
  background: #101115; color: #d7f9d8; padding: 12px; border-radius: 8px; font-family: monospace;
  font-size: 12px; overflow-x: auto; white-space: pre;
}
.footer-note { text-align: center; color: var(--muted); font-size: 11px; padding: 16px; }
