:root {
  --bg: #f4f4f0; --panel: #ffffff; --soft: #f1f1ec; --line: #e4e4dd; --text: #1d1d1b; --muted: #74746c;
  --accent: #2f5d50; --accent-text: #ffffff; --mine: #e3efe9; --other: #ffffff; --hover: #eef2ef;
  --card: #fff8e6; --card-line: #e8d9a8; --ok: #2e8b57; --bad: #c0392b; --warn: #a56f00; --hot: #d4e84a;
  --radius: 14px; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141514; --panel: #1c1d1c; --soft: #242624; --line: #303230; --text: #ecece8; --muted: #9c9c95;
    --accent: #5fa58f; --accent-text: #0e1512; --mine: #23352e; --other: #262826; --hover: #262a28;
    --card: #2e2a1d; --card-line: #5a4d27; --ok: #6cc28f; --bad: #f08a80; --warn: #e0b45a; --hot: #9fb02a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 10px; padding: 6px 12px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.danger-btn { color: var(--bad); }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.error { color: var(--bad); min-height: 1.2em; margin: 4px 0 0; }
.hint { color: var(--muted); font-size: 13px; }
.pad { padding: 12px; }
.spacer { flex: 1; }
.linkbtn { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 4px 6px; cursor: pointer; }
ul.plain { list-style: none; margin: 0; padding: 0; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.brand img { width: 32px; height: 32px; }
.brand.small { font-size: 16px; }
.brand.small img { width: 26px; height: 26px; }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.login-card button[type=submit] { background: var(--accent); color: var(--accent-text); border: 0; padding: 10px; }

/* ===== раскладка: шапка, основная область, правая колонка ===== */
.app { height: 100%; display: grid; grid-template-columns: 1fr minmax(320px, 400px); grid-template-rows: auto 1fr; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.counters { display: flex; gap: 10px; font-size: 13px; color: var(--muted); }
.cnt { cursor: default; } .cnt.hot { background: var(--hot); color: #1d1d1b; border-radius: 8px; padding: 0 6px; cursor: pointer; font-weight: 600; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.ok { background: var(--ok); } .conn.bad { background: var(--bad); }
.userbtn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; }
.userbtn:hover { background: var(--hover); }
.usermenu { position: fixed; right: 16px; top: 52px; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; width: 290px; box-shadow: 0 10px 32px rgba(0,0,0,.18); display: grid; gap: 2px; }
.usermenu button { border: 0; text-align: left; background: transparent; padding: 7px 10px; }
.usermenu button:hover { background: var(--hover); }
.usermenu .danger { color: var(--bad); }
.um-head { display: flex; gap: 10px; align-items: center; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.um-sec { font-size: 12px; color: var(--muted); padding: 8px 10px 2px; text-transform: uppercase; letter-spacing: .4px; }
.um-ver { padding: 4px 10px; }

.main { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.maintabs, .subtabs { display: flex; gap: 4px; padding: 10px 16px 0; }
#llmBar { margin: 10px 16px 0; }
#llmGuide summary { cursor: pointer; }
#llmGuide ol { margin: 8px 0; padding-left: 20px; line-height: 1.5; }
.maintabs button, .subtabs button { border: 0; background: transparent; border-radius: 8px; padding: 6px 14px; color: var(--muted); }
.maintabs button.on, .subtabs button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 0 var(--line); }
.view { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 0; }
.view.page { display: block; overflow-y: auto; padding: 8px 24px 40px; max-width: 980px; }
.page h2 { margin: 12px 0 6px; }
.list-col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); padding: 10px 0 0; }
.detail-col { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.detail-col.scroll { overflow-y: auto; padding: 16px 24px; display: block; }
.newbtn { margin: 0 12px 8px; border: 0; background: var(--soft); text-align: left; font-family: var(--mono); color: var(--accent); font-weight: 600; }
.newbtn:hover { background: var(--hover); }
.search { width: calc(100% - 24px); margin: 0 12px 8px; border-radius: 20px; background: var(--soft); border-color: transparent; padding-left: 14px; }
.searchrow { display: flex; align-items: center; gap: 2px; padding: 10px 8px 6px 12px; }
.searchrow .search { margin: 0; width: auto; flex: 1; }

.seslist { overflow-y: auto; flex: 1; min-height: 0; font-family: var(--mono); font-size: 14px; }
.grp { padding: 12px 14px 4px; border-top: 1px solid var(--line); }
.grp:first-child { border-top: 0; }
.ses { display: flex; gap: 8px; align-items: flex-start; padding: 6px 14px; cursor: pointer; }
.ses:hover { background: var(--hover); } .ses.active { background: var(--mine); }
.ses .sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-top: 7px; flex: none; }
.ses.st-running .sdot { background: var(--warn); animation: pulse 1.2s infinite; }
.ses.st-queued .sdot { background: transparent; border: 2px solid var(--muted); box-sizing: border-box; }
.ses-modes { display: flex; gap: 4px; }
.newses .ses-modes button { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.newses .ses-modes button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.ses.st-waiting .sdot { background: var(--hot); box-shadow: 0 0 0 2px var(--accent); }
.ses.st-error .sdot { background: var(--bad); }
.ses .sm { flex: 1; min-width: 0; }
.ses .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ses .err { color: var(--bad); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ses .tm { color: var(--muted); font-size: 13px; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .3; } }
.newses { margin: auto; width: min(640px, 92%); display: grid; gap: 10px; }
.newses h3 { margin: 0; font-family: var(--mono); color: var(--accent); }
.newses textarea { font-family: var(--mono); resize: vertical; }
.newses button { justify-self: start; }

.agent-li { padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.agent-li:hover { background: var(--hover); } .agent-li.active { background: var(--mine); }
.agent-li .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.agent-head h2 { margin: 6px 0 2px; } .agent-head p { margin: 2px 0; }
.runs { display: grid; gap: 2px; margin-bottom: 10px; }
.run { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 12px; padding: 6px 8px; border-radius: 8px; align-items: baseline; font-size: 14px; }
.run.click { cursor: pointer; } .run.click:hover { background: var(--hover); }
.run .rs { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run.st-error .rs { color: var(--bad); }
.run .tm { color: var(--muted); }
.agent-form { display: grid; gap: 10px; max-width: 760px; }
.agent-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.agent-form textarea { font-family: var(--mono); font-size: 14px; }
label.row { display: flex !important; flex-direction: row; gap: 6px; align-items: center; color: var(--text) !important; font-size: 14px !important; }

.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; display: grid; gap: 10px; justify-items: start; }
.card-box > * { max-width: 100%; }
.card-box h4 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; width: 100%; }
.grid2 label, .card-box > label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.profile-head { display: flex; gap: 16px; align-items: center; margin: 12px 0; }
.profile-head h3 { margin: 0; }
.tabpane { padding-top: 4px; }
.notice { background: var(--mine); border-radius: 8px; padding: 8px; white-space: pre-line; }
.notice:empty { display: none; }
.utable { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); border-radius: 10px; }
.utable th, .utable td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.utable td button { padding: 2px 8px; font-size: 13px; margin: 1px; }
.utable tr.off td { color: var(--muted); }
.utable td.url { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ===== правая колонка: чаты над почтой ===== */
.side { --chats-h: 55%; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chats-pane { height: var(--chats-h); flex: none; }
.mail-pane { border-top: 1px solid var(--line); }
.grip { height: 5px; cursor: row-resize; background: var(--line); flex: none; opacity: .5; }
.grip:hover { opacity: 1; }
.chips { display: flex; gap: 6px; padding: 2px 12px 8px; overflow-x: auto; flex: none; scrollbar-width: none; }
.chips:empty { display: none; }
.chips button { border-radius: 16px; padding: 3px 12px; font-size: 13px; white-space: nowrap; background: var(--soft); border-color: transparent; }
.chips button.on { background: var(--accent); color: var(--accent-text); }
.icon { border: 0; background: transparent; font-size: 18px; padding: 4px 8px; line-height: 1; border-radius: 8px; }
.icon:hover { background: var(--hover); }

.convs { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.conv { display: flex; gap: 10px; padding: 7px 12px; cursor: pointer; align-items: center; }
.conv:hover { background: var(--hover); } .conv.active { background: var(--mine); }
.cb { flex: 1; min-width: 0; }
.top, .bot { display: flex; align-items: center; gap: 6px; min-width: 0; }
.top .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.top .ic { font-size: 12px; }
.top .tm { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bot .l { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bot .l.del { font-style: italic; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 10px; font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; }
.badge.muted { background: var(--muted); }
.badge:empty { min-width: 10px; width: 10px; height: 10px; padding: 0; }
.tick { color: var(--muted); letter-spacing: -3px; margin-right: 3px; }
.tick.read { color: var(--ok); }
.empty-li { padding: 12px; color: var(--muted); font-size: 13px; list-style: none; }
.mail .t { font-weight: 500; } .mail.unseen .t { font-weight: 700; }
.dot-unseen { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pager:empty { display: none; }
.mailfoot { display: flex; justify-content: space-between; align-items: center; padding: 4px 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex: none; }

.ava { width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; position: relative; background: var(--accent); }
.ava img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ava.small { width: 30px; height: 30px; font-size: 11px; }
.ava.big { width: 72px; height: 72px; font-size: 24px; }
.ava .dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }

/* ===== окно переписки ===== */
.chatview { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .ava { width: 34px; height: 34px; font-size: 12px; }
.chat-title { flex: 1; min-width: 0; }
.chat-title .ct { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sesChat .back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.msg { max-width: min(720px, 85%); background: var(--other); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 12px; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--mine); border-color: transparent; }
.msg.system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 13px; text-align: center; max-width: 90%; }
.msg.thinking { animation: pulse 1.4s infinite; }
.msg .a { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.msg .b { white-space: pre-wrap; word-wrap: break-word; }
.msg .m { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.msg.deleted .b { color: var(--muted); font-style: italic; }
.msg img.att { display: block; max-width: 260px; max-height: 220px; border-radius: 10px; margin-top: 6px; }
.msg a.att { display: inline-block; margin-top: 6px; color: var(--accent); }
.more { align-self: center; }
/* ===== задачи и поручения ===== */
.tasks-page:not([hidden]) { display: flex; flex-direction: column; gap: 10px; }
.tk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tk-bar .chips { display: flex; gap: 4px; }
.tk-bar .chips button { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.tk-bar .chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.tk-bar .search { max-width: 220px; margin: 0; }
.tk-body { display: grid; grid-template-columns: 220px 1fr; gap: 12px; min-height: 0; flex: 1; }
.tk-team { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.tk-team h5 { margin: 10px 0 2px; color: var(--muted); font-weight: 600; }
.tk-person { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; border: 1px solid transparent; background: none; border-radius: 10px; padding: 4px 6px; cursor: pointer; align-items: center; }
.tk-person .ava { grid-row: span 2; }
.tk-person small { grid-column: 2; font-size: 11px; }
.tk-person:hover { background: var(--panel); } .tk-person.on { border-color: var(--accent); background: var(--panel); }
.tk-month { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tk-month b { min-width: 150px; text-align: center; text-transform: capitalize; }
.tk-month[hidden], .tk-cal[hidden], .tk-list[hidden] { display: none; }
.tk-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.tk-wd { text-align: center; font-size: 12px; color: var(--muted); padding: 2px; }
.tk-day { min-height: 96px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.tk-day.other { opacity: .5; } .tk-day.weekend { background: var(--bg); }
.tk-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tk-day .n { font-size: 12px; color: var(--muted); text-align: right; }
.tk-chip { display: flex; flex-direction: column; text-align: left; border: 0; border-left: 3px solid #3d5a99; background: #eaf0fb; color: inherit; border-radius: 5px; padding: 2px 5px; font-size: 12px; cursor: pointer; line-height: 1.25; }
.tk-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-chip small { color: var(--muted); font-size: 10px; }
.tk-chip.k-order { border-left-color: #8250df; background: #f3ecfd; }
.tk-chip.st-in_progress { border-left-color: #bf8700; background: #fff6dc; }
.tk-chip.st-done { border-left-color: #2da44e; background: #e8f6ec; text-decoration: line-through; opacity: .75; }
.tk-chip.st-rejected, .tk-chip.st-cancelled { border-left-color: #8c959f; background: #f0f1f2; opacity: .6; }
.tk-chip.overdue { border-left-color: #d1242f; background: #fde8e8; }
.tk-table tr.click { cursor: pointer; } .tk-table tr.overdue td { color: #d1242f; }
.task-dlg { width: min(640px, 94vw); max-height: 90vh; border: 0; border-radius: 14px; padding: 18px 20px; background: var(--panel); color: inherit; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.task-dlg::backdrop { background: rgba(0,0,0,.35); }
.tk-close { position: absolute; right: 10px; top: 8px; }
.tk-form label { display: block; margin-bottom: 8px; }
.tk-form input, .tk-form select, .tk-form textarea { width: 100%; }
.tk-head { display: flex; gap: 8px; align-items: center; }
.tk-badge { border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; background: #eaf0fb; color: #3d5a99; }
.tk-badge.st-in_progress { background: #fff6dc; color: #9a6700; } .tk-badge.st-done { background: #e8f6ec; color: #1a7f37; }
.tk-badge.st-rejected, .tk-badge.st-cancelled { background: #f0f1f2; color: #57606a; }
.tk-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 10px; font-size: 14px; }
.tk-text { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.tk-result { white-space: pre-wrap; border-left: 3px solid #2da44e; padding: 4px 10px; margin-bottom: 10px; }
.task-dlg textarea { width: 100%; }
.tk-acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.tk-events { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.org-wrap { display: grid; grid-template-columns: minmax(280px, 1fr) 1.3fr; gap: 14px; }
.org-tree, .org-tree ul { list-style: none; padding-left: 16px; margin: 0; }
.org-tree { padding-left: 0; }
.org-node { padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.org-node:hover { background: var(--bg); }
.rel-h { margin: 12px 0 4px; color: var(--accent); }
.rel-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; line-height: 1.4; }
.toast.click { cursor: pointer; }
.mem-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 12px; }
.mem-row { display: flex; align-items: center; gap: 8px; }
.mem-row > span { flex: 1; }
.users-pick { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.users-pick label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
@media (max-width: 900px) { .tk-body, .org-wrap { grid-template-columns: 1fr; } .tk-team { flex-direction: row; flex-wrap: wrap; } .tk-day { min-height: 64px; } }
.tpl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.tpl[hidden] { display: none; }
.tpl .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.tpl .chip:hover { border-color: var(--accent); color: var(--accent); }
.help p { margin: 6px 0; line-height: 1.45; }
img.emo { width: 1.25em; height: 1.25em; vertical-align: -0.25em; }
.msg .fwd { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 2px; }
.msg .quote { border-left: 3px solid var(--accent); padding: 2px 8px; margin: 2px 0 4px; font-size: 13px; cursor: pointer; background: rgba(0,0,0,.04); border-radius: 0 6px 6px 0; }
.msg .quote b { display: block; color: var(--accent); font-size: 12px; }
.msg .quote span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg .reacts button { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 1px 8px; font-size: 13px; cursor: pointer; }
.msg .reacts button.on { border-color: var(--accent); color: var(--accent); }
.msg.flash { outline: 2px solid var(--accent); outline-offset: 2px; }
.ctx-emo { display: flex; gap: 2px; padding: 6px 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
#ctx .ctx-emo button { font-size: 22px; padding: 4px; border-radius: 8px; width: auto; line-height: 1; }
#ctx .ctx-emo button:hover { background: var(--bg); transform: scale(1.15); }
#ctx .ctx-emo img.emo { width: 26px; height: 26px; vertical-align: middle; }
.pinbar { display: flex; gap: 8px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 13px; cursor: pointer; }
.pinbar[hidden], .modebar[hidden] { display: none; }
.pinbar b { color: var(--accent); white-space: nowrap; }
.pinbar span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modebar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-left: 3px solid var(--accent); margin: 0 0 6px; background: var(--bg); border-radius: 0 8px 8px 0; font-size: 13px; }
.modebar > div { flex: 1; min-width: 0; }
.modebar b { display: block; color: var(--accent); }
.modebar span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border-color: var(--card-line); }
.card ul { margin: 6px 0; padding-left: 18px; }
.card .acts { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.card .yes { background: var(--accent); color: var(--accent-text); border: 0; }
.card .no { color: var(--bad); }
.card .st { font-weight: 600; } .card .st.approved { color: var(--ok); } .card .st.rejected, .card .st.expired { color: var(--bad); }
.card .timer { color: var(--warn); font-size: 12px; }
.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.composer-row { display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 200px; border-radius: 18px; background: var(--soft); border-color: transparent; }
.send { background: var(--accent); color: var(--accent-text); border: 0; font-size: 18px; padding: 7px 14px; border-radius: 18px; }
.attach { cursor: pointer; padding: 6px; }
.pending { display: flex; flex-wrap: wrap; gap: 6px; }
.pending:empty { display: none; }
.pending .p { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px; font-size: 13px; margin-bottom: 6px; }
.pending img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.pending button { border: 0; background: none; padding: 0 4px; }

/* ===== письмо ===== */
.mv-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex: none; }
.mv-folder { font-weight: 600; }
.mv-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.mv-body h3 { margin: 0; font-size: 17px; }
.mv-meta { color: var(--muted); font-size: 13px; white-space: pre-line; }
.mv-atts { display: flex; flex-wrap: wrap; gap: 6px; }
.mv-atts:empty { display: none; }
.mv-atts a { border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; color: var(--accent); text-decoration: none; font-size: 13px; }
#mvHtml { flex: 1; min-height: 260px; border: 0; background: #fff; width: 100%; border-radius: 8px; }
#mvText { margin: 0; white-space: pre-wrap; font: inherit; }
.mv-acts { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.mailcompose { gap: 6px; padding-bottom: 0; }
.mailcompose > input, .mailcompose > textarea { margin: 0 12px; }
.mailcompose > textarea { flex: 1; min-height: 120px; resize: none; }
.mailcompose > .hint { padding: 0 12px; }

/* ===== меню, всплывающее, диалоги ===== */
.ctx { position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; min-width: 240px; max-width: 320px; box-shadow: 0 10px 32px rgba(0,0,0,.2); display: grid; }
.ctx button { border: 0; text-align: left; background: transparent; padding: 7px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
.ctx button:hover { background: var(--hover); }
.ctx button.danger { color: var(--bad); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.ctx .more-ic { color: var(--muted); }
.ctx-note { padding: 6px 10px; font-size: 13px; color: var(--muted); }
.ctx-input { margin: 4px; }
.toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 8px 14px; border-radius: 10px; z-index: 60; font-size: 14px; max-width: 90%; }
.empty { margin: auto; color: var(--muted); padding: 24px; text-align: center; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); width: min(420px, calc(100% - 32px)); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog h3 { margin: 0; }
.users { max-height: 300px; overflow-y: auto; display: grid; gap: 4px; }
.users label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
.seg { display: flex; gap: 16px; }
.seg label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 15px; }
.profile { display: flex; gap: 14px; align-items: center; white-space: pre-line; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-actions button[value=ok], #pfWrite { background: var(--accent); color: var(--accent-text); border: 0; }

.bottomtabs { display: none; }
.paneltoggles { display: flex; gap: 2px; }
.paneltoggles button { border: 0; background: transparent; padding: 4px 8px; border-radius: 8px; opacity: .45; font-size: 16px; }
.paneltoggles button.on { opacity: 1; background: var(--soft); }
.app.noside { grid-template-columns: 1fr; }
.mailtools { display: flex; align-items: center; gap: 4px; padding: 0 10px 4px 12px; flex: none; }
.mailtools.sel { background: var(--mine); padding-top: 4px; }
.conv.mail input[type=checkbox] { flex: none; }
.top .flag { color: var(--warn); }
#mvFlag.on { color: var(--warn); }
.files-pane { border-top: 1px solid var(--line); }
.ficon { width: 30px; text-align: center; font-size: 20px; flex: none; }
.conv.file { cursor: grab; }
.drop { outline: 2px dashed var(--accent); outline-offset: -6px; background: var(--hover); }
.tip { background: var(--card); border: 1px solid var(--card-line); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 8px; }

/* память, скиллы, объявления, обращения, журнал */
.linkbtn.danger, button.danger { color: var(--bad); }
.page textarea { width: 100%; box-sizing: border-box; }
.page .card-box label:not(.row) { display: grid; gap: 4px; width: 100%; }
.row.inline { display: inline-flex; gap: 6px; align-items: center; margin-left: 12px; }
.memlist .memitem { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.memtext { flex: 1 1 100%; white-space: pre-wrap; }
.skills-wrap { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 16px; align-items: start; }
.skills-wrap .card-box { margin: 0; }
#skBody { font-family: var(--mono); font-size: 13px; }
.ann-body { white-space: pre-wrap; }
.ann.unread { border-left: 4px solid var(--accent); }
.ann.pinned { background: var(--card); }
.newsbtn { position: relative; }
.newsbtn .badge { position: absolute; top: -4px; right: -6px; height: 16px; min-width: 16px; font-size: 10px; padding: 0 4px; }
.usermenu .badge { margin-left: 6px; height: 18px; font-size: 11px; }
.tk-st { font-size: 12px; font-weight: normal; padding: 1px 8px; border-radius: 10px; background: var(--soft); }
.ticket.st-open .tk-st { background: var(--accent); color: var(--accent-text); }
.ticket.st-closed { opacity: .7; }
.tk-answer { background: var(--soft); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; width: 100%; box-sizing: border-box; }
#vTickets .chips { padding-left: 0; align-items: center; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { display: grid; min-width: 110px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.stat b { font-size: 20px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 80px; width: 100%; border-bottom: 1px solid var(--line); }
.bar { flex: 1; max-width: 24px; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.utable tr.warn td { color: var(--bad); }
#aJournal .searchrow { padding: 0; gap: 8px; width: 100%; }
#aJournal h5 { margin: 6px 0; }

/* ===== телефон ===== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .topbar { gap: 8px; padding: 6px 10px; } .clock, .userbtn span:last-child { display: none; }
  .counters { font-size: 12px; gap: 6px; }
  .main, .side { grid-column: 1; grid-row: 2; }
  .app[data-m=sessions] .side, .app[data-m=main] .side { display: none; }
  .app[data-m=chats] .main, .app[data-m=mail] .main, .app[data-m=files] .main { display: none; }
  .app[data-m=chats] .side > :not(#chatsPane), .app[data-m=mail] .side > :not(#mailPane), .app[data-m=files] .side > :not(#filesPane) { display: none !important; }
  .app[data-m=chats] #chatsPane, .app[data-m=mail] #mailPane, .app[data-m=files] #filesPane { display: flex !important; height: auto !important; flex: 1 1 0 !important; }
  .paneltoggles { display: none; }
  .side { border-left: 0; }
  .view { grid-template-columns: 1fr; }
  .view.open .list-col { display: none; }
  .view:not(.open) .detail-col { display: none; }
  #sesChat .back { display: block; }
  .view.page { padding: 8px 12px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .skills-wrap { grid-template-columns: 1fr; }
  #aJournal .searchrow { flex-wrap: wrap; }
  .run { grid-template-columns: 1fr; gap: 0; }
  .msg { max-width: 92%; }
  .utable th:nth-child(2), .utable td:nth-child(2) { display: none; }
  .bottomtabs { display: flex; grid-row: 3; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
  .bottomtabs button { flex: 1; border: 0; background: none; display: grid; justify-items: center; font-size: 18px; padding: 6px 0; color: var(--muted); position: relative; }
  .bottomtabs button span { font-size: 11px; }
  .bottomtabs button.on { color: var(--accent); }
  .bottomtabs button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); position: absolute; top: 2px; left: 55%; background: var(--accent); color: var(--accent-text); font-size: 10px; border-radius: 8px; padding: 0 5px; }
  .usermenu { right: 8px; left: 8px; width: auto; top: auto; bottom: 64px; }
}

/* журналы администратора: раскрытая строка с полным текстом */
pre.wraptext { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0 0 8px; max-height: 50vh; overflow: auto; }
