:root { --bg:#f6f7f9; --card:#fff; --line:#e3e6ea; --text:#1d2129; --muted:#6b7280; --accent:#1f6feb; --red:#d93025; --green:#1a7f37; }
* { box-sizing: border-box; }
body { margin:0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
header.top { display:flex; align-items:center; gap:24px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
header .brand { font-weight: 700; color: var(--text); }
header nav a { margin-right: 14px; color: var(--text); }
header nav a.muted { color: var(--muted); }
main { padding: 16px; }
h1 { font-size: 20px; margin: 0 0 12px; }
button, .btn { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; }
table.kv th { text-align: left; padding: 4px 12px 4px 0; color: var(--muted); font-weight: 500; }
.err { color: var(--red); }
.muted { color: var(--muted); }
/* login */
body.login-body { display:flex; align-items:center; justify-content:center; min-height:100vh; }
form.login { width: 320px; background: var(--card); padding: 24px; border: 1px solid var(--line); border-radius: 10px; display:flex; flex-direction:column; gap:12px; }
form.login h1 { text-align:center; }
form.login label { display:flex; flex-direction:column; gap:4px; color: var(--muted); }
/* inbox */
.inbox { display: grid; grid-template-columns: 320px 1fr 320px; gap: 12px; height: calc(100vh - 80px); }
.inbox aside, .inbox section { background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
.convlist .filters { display:flex; gap:8px; padding: 10px; border-bottom: 1px solid var(--line); align-items:center; }
.convlist .filters a { padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.convlist .filters a.on { background: var(--bg); color: var(--text); font-weight: 600; }
.convlist .filters select { width: auto; margin-left:auto; }
#convs { list-style:none; margin:0; padding:0; }
#convs li a { display:grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
#convs li.active a { background: #eef3ff; }
#convs li.overdue .wait { color: #fff; background: var(--red); }
#convs .wait { font-size: 12px; padding: 1px 6px; border-radius: 10px; background: #fff3cd; }
#convs .last { grid-column: 1 / -1; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#convs li.empty { padding: 20px; color: var(--muted); text-align:center; }
.chan { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); text-transform: uppercase; }
.chan-telegram { background:#e3f2fd; color:#1565c0; } .chan-whatsapp { background:#e8f5e9; color:#2e7d32; } .chan-vk { background:#e8eaf6; color:#283593; }
.chan-max { background:#f3e5f5; color:#6a1b9a; } .chan-site { background:#fff8e1; color:#8d6e00; } .chan-call { background:#fce4ec; color:#ad1457; }
.thread { display:flex; flex-direction:column; }
.thread-head { padding: 10px 14px; border-bottom: 1px solid var(--line); display:flex; gap:10px; align-items:center; }
.msgs { flex:1; overflow:auto; padding: 14px; display:flex; flex-direction:column; gap:8px; }
.msg { display:flex; } .msg.out { justify-content:flex-end; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 12px; background: var(--bg); white-space: pre-wrap; word-break: break-word; }
.msg.out .bubble { background: #dcf0ff; }
.msg.failed .bubble { background: #fdecea; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.att-img { max-width: 260px; max-height: 260px; border-radius: 8px; display:block; margin-top: 4px; }
.reply { display:grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.reply #reply-err { grid-column: 1 / -1; }
.card { padding: 12px; } .card h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.card form.inline { display:flex; gap:6px; margin-bottom:6px; } .card form.inline button { padding: 4px 8px; }
.card .ids { list-style:none; padding:0; margin:0; font-size: 13px; }
.card .btns { display:flex; gap:6px; margin-top:8px; }
.center { text-align:center; margin-top: 40px; }
@media (max-width: 900px) { .inbox { grid-template-columns: 1fr; height:auto; } }
