:root {
  --bg: #f4f5f9;
  --panel: #fff;
  --line: #e6e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #3f6af0;
  --accent-soft: #eef2ff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  font: 14px/1.45 Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 360px; background: var(--panel); border-radius: 18px; padding: 28px; box-shadow: 0 20px 50px -20px rgba(15, 23, 42, .25); display: grid; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0; color: var(--muted); }

/* shell */
.shell { display: grid; grid-template-columns: 212px 1fr; height: 100vh; height: 100dvh; }
.side { background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; font-style: normal; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: inherit; padding: 10px 10px; border-radius: 10px; text-align: left; }
.nav:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav.on { background: rgba(255, 255, 255, .1); color: #fff; }
.nav .cnt { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.side .grow { flex: 1; }
.side .me { font-size: 12px; color: #94a3b8; padding: 0 10px 6px; }
.main { min-width: 0; height: 100%; overflow: hidden; }

/* chats */
.chats { display: grid; grid-template-columns: 340px 1fr 290px; height: 100%; }
.col { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.col:last-child { border-right: 0; }
.filters { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.filters .r { display: flex; gap: 8px; }
.filters select { flex: 1; }
.clist { overflow-y: auto; flex: 1; }
.ci { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid #f0f2f6; cursor: pointer; border-left: 3px solid transparent; }
.ci:hover { background: #fafbfd; }
.ci.on { background: var(--accent-soft); border-left-color: var(--accent); }
.ci .ava { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.ci .b { flex: 1; min-width: 0; }
.ci .t { display: flex; gap: 6px; align-items: center; }
.ci .t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci .t time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ci .p { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.ci .m { display: flex; gap: 6px; margin-top: 4px; align-items: center; }
.ci .un { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: #f1f5f9; color: #334155; white-space: nowrap; }
.tag.bot { background: #ecfdf5; color: #047857; }
.tag.human { background: #fff7ed; color: #c2410c; }
.tag.flag { background: #fef2f2; color: var(--bad); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.convhead { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.convhead h2 { margin: 0; font-size: 16px; }
.convhead .sp { flex: 1; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 16px; background: #f8f9fc; display: flex; flex-direction: column; gap: 10px; }
.mr { display: flex; flex-direction: column; max-width: 72%; }
.mr.ours { align-self: flex-end; align-items: flex-end; }
.mr .who { font-size: 11.5px; color: var(--muted); margin: 0 4px 3px; }
.mr .bb { padding: 9px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.mr.ours .bb { background: var(--accent); border-color: transparent; color: #fff; }
.mr.ours.op .bb { background: #0f172a; }
.mr.blocked .bb { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.mr.sus .bb { border-color: #fca5a5; }
.mr details { font-size: 12px; color: #9a3412; margin-top: 4px; max-width: 100%; }
.mr details pre { white-space: pre-wrap; background: #fff; border: 1px solid #fed7aa; padding: 8px; border-radius: 8px; color: #431407; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: #eef0f5; padding: 3px 10px; border-radius: 999px; }
.compose { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 6px; background: #fff; }
.compose .r { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }

.info { padding: 16px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }
.info h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; gap: 2px; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 500; overflow-wrap: anywhere; }

/* forms */
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.btn { border: 0; border-radius: 10px; padding: 9px 16px; background: var(--accent); color: #fff; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--text); border: 1.5px solid var(--line); }
.btn.warn { background: #ea580c; }
.btn.dark { background: #0f172a; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }
.ok { color: var(--ok); font-size: 13px; }

.page { height: 100%; overflow-y: auto; padding: 24px; }
.page > .in { max-width: 880px; margin: 0 auto; display: grid; gap: 18px; padding-bottom: 80px; }
.page h1 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 6px; }
.tabs button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 16px; font-weight: 600; }
.tabs button.on { background: var(--text); border-color: var(--text); color: #fff; }
.card { background: var(--panel); border-radius: 16px; padding: 20px; box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); display: grid; gap: 14px; }
.card h2 { margin: 0; font-size: 16px; }
.card .sub { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label.f { display: grid; gap: 6px; }
label.f > span { font-size: 13px; font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; text-align: left; display: grid; gap: 2px; }
.seg button b { font-size: 14px; }
.seg button span { font-size: 12px; color: var(--muted); }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.langs { display: flex; flex-wrap: wrap; gap: 8px; }
.langs label { display: flex; gap: 6px; align-items: center; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff; }
.avrow { display: flex; gap: 14px; align-items: center; }
.avbig { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 26px; overflow: hidden; flex: none; }
.avbig img { width: 100%; height: 100%; object-fit: cover; }
.ltext { display: grid; gap: 10px; }
.ltext .lh { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 12px 16px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-radius: 14px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px -10px rgba(15, 23, 42, .2); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 12px; overflow-x: auto; margin: 0; white-space: pre-wrap; word-break: break-all; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.status.on i { background: var(--ok); }
.note { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; border-radius: 12px; padding: 12px 14px; font-size: 13px; }

.back { display: none; }
@media (max-width: 1100px) {
  .chats { grid-template-columns: 300px 1fr; }
  .chats .info { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; padding: 8px; overflow-x: auto; align-items: center; }
  .brand, .side .grow, .side .me { display: none; }
  .nav { width: auto; padding: 8px 10px; }
  .chats { grid-template-columns: 1fr; }
  .chats.conv-open .col.list { display: none; }
  .chats:not(.conv-open) .col.conv { display: none; }
  .back { display: inline-flex; }
  .grid2, .seg { grid-template-columns: 1fr; }
  .page { padding: 14px; }
}
