/* AI Team Chat — SCB-dark */
:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --border: #262626;
  --text: #e2e2e2;
  --muted: #8a8a8a;
  --accent: #aaf383;
  --accent-dim: #7fbf5e;
  --danger: #ff7a7a;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
button:hover { border-color: var(--accent-dim); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-weight: 700;
}
button.primary:hover { background: #bdf79d; }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: default; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-dim); }
::placeholder { color: #5d5d5d; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.accent { color: var(--accent); }

/* ---------- login ---------- */
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.logo em { color: var(--accent); font-style: normal; }
.error-line { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- app layout ---------- */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar .top { padding: 18px 16px 10px; }
.sidebar .logo { font-size: 18px; margin-bottom: 14px; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.conv-item {
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c9c9c9;
  font-size: 13.5px;
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--panel-2); color: var(--text); }
.conv-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .del { opacity: 0; border: none; background: none; padding: 2px 5px; color: var(--muted); }
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: var(--danger); }
.sidebar .bottom {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.userline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.userline .who { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.linkbtn { background: none; border: none; padding: 2px 0; color: var(--muted); font-size: 12.5px; text-align: left; }
.linkbtn:hover { color: var(--accent); border: none; }

/* ---------- chat ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
}
.chat-header .conv-title {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-seg { display: flex; max-width: 72%; overflow-x: auto; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.model-seg button { flex: 0 0 auto; white-space: nowrap; border: none; background: none; padding: 5px 14px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.model-seg button.on { background: var(--accent); color: #0a0a0a; font-weight: 700; }
.messages { flex: 1; overflow-y: auto; padding: 26px 0; }
.msg { max-width: 760px; margin: 0 auto 22px; padding: 0 26px; }
.msg .role { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.msg.user .role { color: var(--accent-dim); }
.msg.user .body {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  white-space: pre-wrap;
}
.msg.assistant .body { padding: 0 2px; }
.msg .meta { margin-top: 6px; font-size: 11.5px; color: #5d5d5d; }
.empty-state {
  max-width: 760px; margin: 12vh auto 0; padding: 0 26px; text-align: center; color: var(--muted);
}
.empty-state h2 { color: var(--text); font-weight: 800; letter-spacing: -.02em; }

/* markdown */
.body :is(p, ul, ol) { margin: 0 0 10px; }
.body :is(h1,h2,h3,h4) { margin: 18px 0 8px; letter-spacing: -.01em; }
.body pre {
  background: #101010;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 13px;
}
.body code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .92em; background: #101010; border-radius: 5px; padding: 1px 5px; }
.body pre code { background: none; padding: 0; }
.body blockquote { margin: 0 0 10px; padding: 2px 14px; border-left: 3px solid var(--accent-dim); color: #bdbdbd; }
.body table { border-collapse: collapse; margin: 0 0 12px; display: block; overflow-x: auto; }
.body th, .body td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13.5px; }
.body a { text-decoration: underline; }

/* composer */
.composer { padding: 14px 26px 22px; }
.composer-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}
.composer textarea {
  flex: 1; border: none; background: none; resize: none;
  max-height: 220px; padding: 6px 8px;
}
.composer .hint { max-width: 760px; margin: 8px auto 0; text-align: center; }

/* ---------- admin ---------- */
.admin-wrap { max-width: 1060px; margin: 0 auto; padding: 26px 24px 60px; }
.admin-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.admin-head .logo { flex: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; }
.tabs button { border-radius: 10px; color: var(--muted); }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #0a0a0a; font-weight: 700; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: -.01em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.grid td { padding: 9px 10px; border-bottom: 1px solid #1e1e1e; font-size: 13.5px; vertical-align: middle; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; border: 1px solid var(--border); color: var(--muted); }
.pill.ok { color: var(--accent); border-color: var(--accent-dim); }
.pill.off { color: var(--danger); border-color: #5a2e2e; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* dialogs */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  min-width: 340px;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 0 0 14px; }
dialog form { display: flex; flex-direction: column; gap: 10px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.pwbox {
  font-family: ui-monospace, Menlo, monospace;
  background: #101010; border: 1px dashed var(--accent-dim);
  border-radius: 8px; padding: 10px 12px; font-size: 15px; letter-spacing: .04em;
  user-select: all;
}

@media (max-width: 900px) {
  .chat-header { align-items: stretch; flex-direction: column; gap: 8px; padding: 10px 16px; }
  .model-seg { max-width: 100%; }
  .model-seg button { padding-inline: 11px; }
}
