:root {
  --bg: #f4f5f7; --panel: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6ec;
  --nav: #1f2a44; --nav-text: #c9d2e3; --accent: #2457c5; --accent-bg: #e8effc;
  --ok: #18794e; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fdf1d8;
  --bad: #b42318; --bad-bg: #fde8e6; --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
nav.side { width: 214px; background: var(--nav); color: var(--nav-text); padding: 16px 0; flex-shrink: 0; }
nav.side a.brand { display: flex; align-items: center; gap: 10px; padding: 0 16px 18px; color: #fff;
  font-weight: 600; font-size: 17px; line-height: 1.2; white-space: nowrap; }
nav.side a.brand:hover { background: none; }
nav.side .brand img { flex-shrink: 0; }
nav.side .brand small, .login-brand small { display: block; margin-top: 3px; font-weight: 500; font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase; color: #d4a83a; white-space: nowrap; }
nav.side .brand small i, .login-brand small i { font-style: normal; opacity: .7; padding: 0 2px; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand b { font-size: 20px; font-weight: 600; }
nav.side a { display: block; padding: 8px 20px; color: var(--nav-text); }
nav.side a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
nav.side a.on { background: rgba(255,255,255,.12); color: #fff; border-left: 3px solid #7aa2ff; padding-left: 17px; }
nav.side .who { padding: 16px 20px 0; margin-top: 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
nav.side .who button { margin-top: 8px; }
main { flex: 1; min-width: 0; padding: 24px 28px; max-width: 1200px; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.metric .l { color: var(--muted); font-size: 13px; }
.metric .v { font-size: 24px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
.pre { white-space: pre-wrap; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; background: #eef0f4; color: #404a5c; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-acc { background: var(--accent-bg); color: var(--accent); }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.stopbar { background: var(--bad); color: #fff; padding: 8px 32px; font-weight: 600; }
form.inline { display: inline; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; background: #fff; }
textarea { min-height: 90px; }
input[type=checkbox] { margin-right: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 160px; }
.row > .narrow { flex: 0 0 auto; min-width: 0; }
button, .btn { display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid #b9c0cc; background: #fff;
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
button:hover, .btn:hover { background: #f1f3f6; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d47a3; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { border-color: rgba(255,255,255,.3); background: transparent; color: var(--nav-text); }
.bar { height: 6px; background: #eceef2; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 6px; background: var(--ok); }
.bar i.warn { background: #e0a100; }
.w0{width:0}.w10{width:10%}.w20{width:20%}.w30{width:30%}.w40{width:40%}.w50{width:50%}.w60{width:60%}
.w70{width:70%}.w80{width:80%}.w90{width:90%}.w100{width:100%}
.voice { font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.6; }
.perm td:first-child { width: 55%; }
.login { max-width: 380px; margin: 10vh auto; }
.sep { border-top: 1px solid var(--line); margin: 16px 0; }
details summary { cursor: pointer; color: var(--accent); }
video, img.att { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.kb { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.kb-list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.kb-list a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.kb-list a:last-child { border-bottom: 0; }
.kb-list a:hover { background: #f6f7f9; text-decoration: none; }
.kb-list a.on { background: var(--accent-bg); border-left: 3px solid var(--accent); padding-left: 11px; }
.kb-list a span { display: block; }
.kb-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kb-head h3 { margin: 0; }
td.num { width: 44px; color: var(--muted); }
.mt0 { margin-top: 0; }
.assist { margin-bottom: 4px; }
button.link { border: 0; background: none; padding: 0 4px; color: var(--bad); font-size: 13px; text-decoration: underline; }
a.metric { color: var(--text); }
a.metric:hover { text-decoration: none; border-color: var(--accent); }
.att-item { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 12px; }
label.inline-check { display: inline; margin: 0; color: var(--text); }
@media (max-width: 900px) { .kb { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .layout { display: block; } nav.side { width: auto; } main { padding: 16px; } }
.kb-empty { padding: 10px 14px; margin: 0; }
.login-brand small { color: #a87c16; }
.pick-search { width: 100%; padding: 6px 10px; margin-bottom: 4px; border: 1px solid #cfd4dc; border-radius: 6px;
  font: inherit; font-size: 14px; background: #fbfcfe; }
.pick-search.pick-none { border-color: var(--bad); background: var(--bad-bg); }
details.inline-edit { margin-top: 4px; }
details.inline-edit summary { font-size: 13px; }
details.inline-edit form { margin-top: 6px; }

.ref-field { display: flex; gap: 6px; align-items: flex-start; }
.ref-field > select, .ref-field > .ref-checks { flex: 1; }
.ref-checks { padding: 4px 0; }
button.ref-open { padding: 6px 12px; font-weight: 600; }
dialog.ref { width: min(640px, 92vw); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; }
dialog.ref::backdrop { background: rgba(20, 28, 45, .45); }
dialog.ref h3 { margin-top: 0; }
dialog.ref .ref-list { margin: 8px 0 14px; max-height: 50vh; overflow: auto; display: block; }
dialog.ref .ref-list td:last-child { width: 1%; white-space: nowrap; }
.err-text { color: var(--bad); }
dialog.ref .ref-search { width: 100%; padding: 7px 10px; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; }
/* discussion of a task */
.thread { margin: 0 0 8px; }
.msg { border-left: 3px solid var(--line); padding: 6px 12px; margin-bottom: 8px; }
.msg.ai { border-color: var(--warn); background: var(--warn-bg); border-radius: 0 var(--radius) var(--radius) 0; }
.msg.system { border-color: var(--line); color: var(--muted); font-size: 13px; }
.msg .who { font-size: 12px; color: var(--muted); }
/* chats: a messenger */
main:has(> .tg) { padding: 0; max-width: none; }
.tg { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100vh; background: var(--panel); }
.tg-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.tg-search { padding: 12px; border-bottom: 1px solid var(--line); }
.tg-search input { width: 100%; border-radius: 18px; background: var(--bg); border-color: transparent; }
.tg-rows { overflow-y: auto; flex: 1; }
.tg-row { display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--text); }
.tg-row[hidden] { display: none; }
.tg-row:hover { background: var(--bg); text-decoration: none; }
.tg-row.on { background: var(--accent); color: #fff; }
.tg-row.on .tg-preview, .tg-row.on time { color: rgba(255,255,255,.8); }
.tg-row-body { flex: 1; min-width: 0; }
.tg-row-top, .tg-row-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.tg-row-top b { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-row time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.tg-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-unread { background: var(--accent); color: #fff; border-radius: 10px; min-width: 20px; padding: 0 6px; text-align: center; font-size: 12px; line-height: 20px; flex-shrink: 0; }
.tg-row.on .tg-unread { background: #fff; color: var(--accent); }
.ava { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; font-weight: 600; font-size: 16px; }
.ava-ai { background: var(--nav); color: #f0c35a; font-size: 14px; }
.ava-0 { background: #2457c5; } .ava-1 { background: #18794e; } .ava-2 { background: #8a5a00; } .ava-3 { background: #7a3e9d; } .ava-4 { background: #b42318; }
.tg-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #e9edf3; }
.tg-head { display: flex; gap: 10px; align-items: center; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tg-back { display: none; font-size: 20px; padding: 0 8px 0 0; }
.tg-thread { flex: 1; overflow-y: auto; padding: 16px 10%; }
.tg-empty { flex: 1; height: 100%; display: flex; align-items: center; justify-content: center; }
.tg-empty span, .tg-day span { background: rgba(31,42,68,.55); color: #fff; border-radius: 12px; padding: 3px 12px; font-size: 13px; }
.tg-day { text-align: center; margin: 12px 0; }
.tg-note span { background: var(--warn-bg); color: var(--warn); display: inline-block; }
.tg-line { display: flex; margin-bottom: 4px; }
.tg-line.mine { justify-content: flex-end; }
.bubble { background: var(--panel); border-radius: 12px 12px 12px 3px; padding: 6px 10px 5px; max-width: min(70%, 560px); box-shadow: 0 1px 1px rgba(31,42,68,.12); overflow-wrap: anywhere; }
.mine .bubble { background: #d6e4fb; border-radius: 12px 12px 3px 12px; }
.bubble.q { background: var(--warn-bg); }
.bubble time { float: right; margin: 6px 0 0 12px; font-size: 11px; color: var(--muted); }
.bubble-who { font-size: 13px; font-weight: 600; color: var(--accent); }
.bubble-tag { font-size: 12px; font-weight: 600; color: var(--warn); }
.bubble-task { display: block; font-size: 12px; border-left: 2px solid var(--accent); padding-left: 6px; margin: 2px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-line { align-items: center; gap: 4px; }
.tg-line.mine { flex-direction: row-reverse; justify-content: flex-start; }
.bubble-quote { border-left: 2px solid var(--accent); padding-left: 6px; margin: 2px 0 4px; font-size: 13px; }
.bubble-quote b { display: block; color: var(--accent); font-weight: 600; }
.bubble-quote span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.bubble-answer { display: block; clear: both; margin-top: 6px; background: var(--accent); border-color: var(--accent); color: #fff; font-size: 13px; }
.bubble-reacts { clear: both; display: flex; flex-wrap: wrap; gap: 4px; }
.bubble-reacts:not(:empty) { padding-top: 4px; }
.react { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 0 8px; font-size: 13px; line-height: 22px; }
.react.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.bubble-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .1s; }
.tg-line:hover .bubble-actions, .bubble-actions:focus-within { opacity: 1; }
@media (hover: none) { .bubble-actions { opacity: .7; } }
.bubble-actions button { border: 0; background: rgba(31,42,68,.08); border-radius: 50%; width: 26px; height: 26px; padding: 0; font-size: 14px; line-height: 26px; color: var(--muted); }
.bubble-actions button:hover { background: rgba(31,42,68,.18); color: var(--text); }
.react-wrap { position: relative; }
.react-pop { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 2px; padding: 4px; background: var(--panel); border-radius: 18px; box-shadow: 0 2px 10px rgba(31,42,68,.25); }
.react-pop[hidden] { display: none; }
.bubble-actions .react-pop button { background: transparent; width: 30px; height: 30px; font-size: 17px; line-height: 30px; }
.bubble-actions .react-pop button:hover { background: var(--bg); }
.tg-replybar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.tg-replybar[hidden] { display: none; }
.tg-replybar > div { min-width: 0; border-left: 2px solid var(--accent); padding-left: 8px; font-size: 13px; }
.tg-replybar b { display: block; color: var(--accent); font-weight: 600; }
.tg-replybar span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-replybar button { border: 0; background: transparent; font-size: 20px; padding: 0 6px; color: var(--muted); }
.typing { display: flex; gap: 4px; padding: 10px 12px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: tg-dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes tg-dot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; } }
.tg-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.tg-compose textarea { flex: 1; min-height: 40px; max-height: 160px; resize: none; border-radius: 20px; padding: 9px 14px; background: var(--bg); border-color: transparent; }
.tg-send { width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; background: var(--accent); color: #fff; font-size: 16px; flex-shrink: 0; }
.tg-topic { height: 40px; border-radius: 20px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
.tg-blocked { padding: 14px 16px; text-align: center; color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); font-size: 14px; }
@media (max-width: 900px) {
  .tg { grid-template-columns: minmax(0, 1fr); }
  .tg.open .tg-list { display: none; }
  .tg:not(.open) .tg-main { display: none; }
  .tg-back { display: inline; }
  .tg-thread { padding: 12px; }
  .bubble { max-width: 85%; }
}
.bubble-open { display: table; clear: both; margin-top: 6px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.chip { padding: 4px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); font-size: 14px; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.hot b { color: var(--bad); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on b { color: #fff; }
a.sort { color: inherit; white-space: nowrap; }
