/* Сайт TenKrol — каркас `/app/*`.
   Дизайн-система из утверждённого макета (site-preview.html, ред. 2):
   тёмная тема, те же цвета и типографика. Ноль зависимостей. */

:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212c;
  --panel-3: #1b2632;
  --line: #24303d;
  --line-2: #2f3d4d;
  --text: #e8edf2;
  --muted: #93a1b0;
  --faint: #6d7c8c;
  --green: #3ddc97;
  --green-soft: #12251d;
  --green-line: #2c6b4d;
  --blue: #5aa9ff;
  --blue-soft: #111d29;
  --blue-line: #2c4f74;
  --amber: #ffb86b;
  --amber-soft: #241c10;
  --amber-line: #5d472a;
  --violet: #b48cff;
  --violet-soft: #1e1729;
  --pink: #ff8fb1;
  --pink-soft: #241318;
  --pink-line: #63323f;
  --topbar: 58px;
  --tabbar: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1100px 600px at 15% -10%, #12251f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* ---------------- загрузка ---------------- */
.boot {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 13px;
}
.boot b { color: var(--text); font-size: 17px; letter-spacing: -.01em; }
.boot-mark {
  width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--green), var(--blue)); color: #07110c;
  font-weight: 800; font-size: 24px; margin-bottom: 6px; box-shadow: 0 12px 30px rgba(61, 220, 151, .18);
}
.noscript { padding: 30px; color: var(--muted); }

/* ---------------- вход ---------------- */
.auth {
  min-height: 100dvh; height: 100dvh; display: flex; align-items: flex-start; justify-content: center;
  padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  position: relative; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-glow {
  position: absolute; inset: -30% -20% auto; height: 70vh; pointer-events: none;
  background: radial-gradient(500px 320px at 50% 30%, rgba(61, 220, 151, .16), transparent 70%);
}
.auth-card {
  position: relative; width: min(100%, 400px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow);
  margin: auto 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--green), var(--blue)); color: #07110c;
  font-weight: 800; font-size: 17px; flex: 0 0 36px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-auth { margin-bottom: 18px; }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.auth-lead { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.field { display: block; margin-bottom: 11px; }
.field > span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.input {
  width: 100%; height: 42px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel-2); padding: 0 12px; color: var(--text); font-size: 14px;
}
.input:focus { border-color: var(--blue); outline: none; }
.auth-error { color: var(--pink); background: var(--pink-soft); border: 1px solid var(--pink-line); border-radius: 9px; padding: 8px 10px; font-size: 12px; margin: 0 0 10px; }
.auth-foot { color: var(--faint); font-size: 11px; text-align: center; margin: 14px 0 0; }
.btn {
  min-height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 0 14px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line-2);
  color: var(--muted); background: transparent; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--faint); }
.btn-primary { background: #1c4a36; border-color: var(--green-line); color: var(--green); }
.btn-primary:hover { background: #20583f; color: #bff5da; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--muted); }
.btn-danger { background: var(--pink-soft); border-color: var(--pink-line); color: var(--pink); }
.btn-danger:hover { background: #2c171d; color: #ffc0d2; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 11px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------------- каркас ---------------- */
.app { height: 100dvh; min-height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; flex: 0 0 auto; min-height: calc(var(--topbar) + var(--safe-top));
  display: flex; align-items: center; gap: 10px; padding: var(--safe-top) 12px 0;
  border-bottom: 1px solid var(--line); background: rgba(11, 15, 20, .88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand-top .brand-name { display: none; }
.pagehead { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; line-height: 1.25; }
.pagehead b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pagehead span { color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mainnav { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--muted); background: transparent; flex: 0 0 34px;
}
.icon-btn:hover { color: var(--text); border-color: var(--faint); }
.icon-btn .ic { width: 16px; height: 16px; }
#new-work-btn { color: var(--green); }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2);
  display: grid; place-items: center; color: #0a1220; font-weight: 700; font-size: 12px;
  background: linear-gradient(140deg, var(--violet), var(--blue)); flex: 0 0 34px;
}
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tabbar {
  flex: 0 0 auto; position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  display: flex; align-items: stretch; border-top: 1px solid var(--line);
  background: rgba(18, 24, 33, .96); backdrop-filter: blur(14px);
  padding: 6px 2px calc(6px + var(--safe-bottom));
}
.tabbtn {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--faint); font-size: 9.5px; line-height: 1.2; padding: 2px 0; text-decoration: none;
}
.tabbtn .ic { width: 19px; height: 19px; }
.tabbtn.on { color: var(--green); }
.tabbtn:hover { color: var(--text); }
body[data-detail="1"] .tabbar { display: none; }
body[data-detail="1"] .main { padding-bottom: 0; }
.main { padding-bottom: calc(var(--tabbar) + var(--safe-bottom)); }

/* ---------------- страницы ---------------- */
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px 14px 24px; overflow: auto; flex: 1; min-height: 0; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin: 2px 0 14px; }
.page-head h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; font-weight: 650; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 11.5px; }
.page-head .spacer { flex: 1; }
.section { margin-top: 18px; }
.section-title {
  display: flex; align-items: center; gap: 7px; margin: 0 0 8px;
  color: var(--faint); font-size: 9.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.section-title .ic { width: 13px; height: 13px; }
.section-title .count { margin-left: auto; color: var(--faint); letter-spacing: 0; text-transform: none; font-weight: 500; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-width: 0; }
.card-soft { background: var(--panel-2); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 11px; }
.tiny { font-size: 10px; }
.mono { font-family: var(--mono); }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.note { color: var(--faint); font-size: 10.5px; line-height: 1.45; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; text-align: center; color: var(--muted); padding: 30px 16px; min-height: 180px;
}
.empty-state .ic { width: 30px; height: 30px; color: var(--faint); }
.empty-state b { color: var(--text); font-size: 13px; }
.empty-state span { font-size: 11.5px; max-width: 360px; }
.skeleton {
  background: linear-gradient(90deg, #16202b 25%, #1d2936 37%, #16202b 63%);
  background-size: 400% 100%; animation: shimmer 1.2s ease-in-out infinite; border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.spinner {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line-2);
  border-top-color: var(--green); animation: spin .8s linear infinite; flex: 0 0 15px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- чаты: общий каркас ---------------- */
.chats-layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr);
  /* Без явной строки auto-трек растягивается по содержимому и выносит
     поле ввода за экран; minmax(0, 1fr) держит его в высоте каркаса. */
  grid-template-rows: minmax(0, 1fr); overflow: hidden;
}
.chatlist-pane { min-height: 0; display: flex; flex-direction: column; border-right: 0; overflow: hidden; }
.chat-main { min-height: 0; display: none; flex-direction: column; overflow: hidden; position: relative; }
.agent-pane { display: none; min-height: 0; overflow: auto; border-left: 1px solid var(--line); padding: 12px; }
.pane-head { flex: 0 0 auto; padding: 8px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.pane-title { display: flex; align-items: center; gap: 8px; }
.pane-title b { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.pane-title span { color: var(--muted); font-size: 10.5px; margin-left: auto; white-space: nowrap; }
.searchbox {
  height: 34px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; gap: 7px; padding: 0 10px; color: var(--faint); font-size: 12px;
}
.searchbox .ic { width: 14px; height: 14px; }
.searchbox input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font-size: 12.5px; }
.searchbox input::placeholder { color: var(--faint); }
.chips { display: flex; gap: 5px; overflow: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 10.5px; background: transparent; white-space: nowrap;
}
.chip.on { background: #16261f; border-color: var(--green-line); color: var(--green); }
.chatlist { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 10px; overscroll-behavior: contain; }
.grouplabel { font-size: 9.5px; color: var(--faint); letter-spacing: .12em; text-transform: uppercase; padding: 8px 8px 4px; }
.chatrow {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: 12px; text-align: left; position: relative; color: var(--text);
}
.chatrow + .chatrow::before { content: ""; position: absolute; left: 60px; right: 8px; top: 0; height: 1px; background: #18222d; }
.chatrow.on { background: #16261f; box-shadow: inset 0 0 0 1px #254636; }
.chatrow.on::before, .chatrow.on + .chatrow::before { display: none; }
.chatrow:hover { background: #141c25; }
.chatrow.on:hover { background: #16261f; }
.cav {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #08110c; position: relative; letter-spacing: -.02em;
}
.av-bot { background: linear-gradient(140deg, #3ddc97, #2f9be0); }
.av-group { background: linear-gradient(140deg, #ffb86b, #ff8fb1); color: #2a1105; }
.av-sec { background: linear-gradient(140deg, #b48cff, #5aa9ff); }
.av-prj { background: linear-gradient(140deg, #5aa9ff, #3ddc97); color: #04121c; }
.av-home { background: linear-gradient(140deg, #ffd479, #3ddc97); color: #1d1503; }
.cav .on-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }
.cbody { flex: 1; min-width: 0; }
.ctop { display: flex; align-items: baseline; gap: 6px; }
.cname { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctime { flex: 0 0 auto; color: var(--faint); font-size: 10px; white-space: nowrap; }
.cprev { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.cmeta { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; align-self: flex-start; margin-top: 2px; }
.unread {
  min-width: 17px; height: 17px; border-radius: 9px; background: var(--green); color: #08110c;
  font-size: 9.5px; font-weight: 700; display: grid; place-items: center; padding: 0 5px;
}
.mutedot { width: 7px; height: 7px; border-radius: 50%; background: #3a4a5a; margin-top: 4px; }
.list-foot { padding: 8px 8px 2px; color: var(--faint); font-size: 10px; text-align: center; }

/* ---------------- чат ---------------- */
.chat-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px; padding: 7px 12px 8px;
  border-bottom: 1px solid var(--line); background: rgba(18, 24, 33, .55);
}
.backbtn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-2);
  display: grid; place-items: center; color: var(--blue); flex: 0 0 32px;
}
.backbtn .ic { width: 17px; height: 17px; }
.chat-head .cav { width: 34px; height: 34px; flex-basis: 34px; font-size: 11.5px; }
.chat-who { flex: 1; min-width: 0; }
.chat-who b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who span { display: block; color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-actions { display: flex; gap: 5px; }
.chat-body {
  flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 14px;
  display: flex; flex-direction: column; gap: 7px; overscroll-behavior: contain;
}
.daydiv {
  align-self: center; color: #7c8794; font-size: 10px; background: #151d26;
  border: 1px solid var(--line); padding: 3px 10px; border-radius: 99px; margin: 6px 0 2px;
}
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: min(86%, 680px); min-width: 0; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg + .msg.same { margin-top: -3px; }
.bubble {
  padding: 7px 10px 6px; border-radius: 15px; font-size: 12.8px; line-height: 1.42;
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 5px;
  white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0;
}
.msg.out .bubble { background: #1c3b2c; border-color: #2b5a43; border-bottom-left-radius: 15px; border-bottom-right-radius: 5px; }
.bubble .author { font-size: 10.5px; color: var(--blue); font-weight: 600; margin-bottom: 2px; }
.msg-meta { display: flex; align-items: center; gap: 5px; color: #7f8d9c; font-size: 9.5px; margin-top: 3px; padding: 0 3px; }
.msg-meta .sendstate { color: var(--green); }
.attach {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 8px;
  border-radius: 9px; background: #0f1720; border: 1px solid var(--line-2); color: var(--text);
}
.attach .aic { width: 26px; height: 26px; border-radius: 7px; background: #1b2a38; display: grid; place-items: center; color: var(--blue); flex: 0 0 26px; }
.attach .an { display: block; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach .as { display: block; font-size: 9.5px; color: var(--muted); }
.attach img { max-width: 220px; max-height: 180px; border-radius: 7px; display: block; }

/* карточка работы в чате */
.workcard {
  align-self: flex-start; width: min(92%, 460px); background: #111d29; border: 1px solid #243a52;
  border-radius: 12px; padding: 9px 11px; margin: 1px 0 3px;
}
.workcard.done { background: #10251c; border-color: #234a37; }
.workcard.error { background: #241318; border-color: var(--pink-line); }
.workcard.cancelled { background: #171d24; border-color: var(--line-2); }
.wc-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wc-top .ic { width: 14px; height: 14px; color: var(--blue); flex: 0 0 14px; }
.wc-title { flex: 1; min-width: 0; font-size: 11.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-meta { color: var(--muted); font-size: 10.2px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.wc-meta .sep { color: var(--line-2); }
.wc-actions { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.wc-actions .btn { min-height: 28px; font-size: 10.5px; padding: 0 9px; }
.wc-actions .btn[disabled] { opacity: .55; cursor: default; }

.pill {
  flex: 0 0 auto; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 99px;
  border: 1px solid; letter-spacing: .02em; white-space: nowrap;
}
.pill.ok { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.pill.run { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }
.pill.wait { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.pill.err { color: var(--pink); border-color: var(--pink-line); background: var(--pink-soft); }
.pill.off { color: var(--muted); border-color: var(--line-2); background: #171d24; }

.composer {
  flex: 0 0 auto; border-top: 1px solid var(--line); padding: 8px 10px calc(8px + var(--safe-bottom));
  display: flex; gap: 7px; align-items: flex-end; background: rgba(18, 24, 33, .92);
}
.composer .field-wrap {
  flex: 1; min-width: 0; display: flex; align-items: flex-end; border-radius: 16px;
  background: var(--panel-2); border: 1px solid var(--line); padding: 3px 11px;
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: none;
  color: var(--text); font-size: 13px; line-height: 1.4; padding: 7px 0; max-height: 120px;
}
.composer textarea::placeholder { color: var(--faint); }
.sendbtn {
  width: 36px; height: 36px; border-radius: 50%; background: #1c4a36; border: 1px solid var(--green-line);
  display: grid; place-items: center; color: var(--green); flex: 0 0 36px;
}
.sendbtn[disabled] { opacity: .5; cursor: default; }
.sendbtn .ic { width: 17px; height: 17px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; }

/* ---------------- панель агента на десктопе ---------------- */
.agent-pane .pane-section + .pane-section { margin-top: 14px; }
.agent-pane h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--faint); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.agent-pane h3 a { margin-left: auto; font-size: 9.5px; letter-spacing: 0; text-transform: none; font-weight: 600; color: var(--blue); }
.acard2 { background: var(--panel-2); border: 1px solid var(--blue-line); border-radius: 11px; padding: 9px 10px; }
.acard2 .row { gap: 6px; }
.acard2 .at { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acard2 .am { color: var(--muted); font-size: 9.5px; margin-top: 3px; }
.prog { height: 5px; border-radius: 3px; background: #1c2530; overflow: hidden; margin-top: 8px; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); min-width: 8%; transition: width .4s ease; }
.psumbox { display: flex; gap: 7px; margin-bottom: 10px; }
.psumbox > div { flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.psumbox b { display: block; font-size: 13px; line-height: 1.2; }
.psumbox span { display: block; color: var(--muted); font-size: 8.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow { display: flex; align-items: center; gap: 7px; padding: 6px 1px; border-bottom: 1px dashed #1c2632; min-width: 0; color: var(--text); }
.arow:last-child { border-bottom: 0; }
.arow .st2 { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: var(--faint); }
.arow .st2.ok { background: var(--green); } .arow .st2.run { background: var(--blue); }
.arow .st2.wait { background: var(--amber); } .arow .st2.err { background: var(--pink); }
.arow .an { flex: 1; min-width: 0; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.arow .am { flex: 0 0 auto; color: var(--faint); font-size: 9px; white-space: nowrap; }
.agent-pane .newbtn { margin-top: 10px; width: 100%; }

/* ---------------- работы ---------------- */
.works-strip {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; margin-bottom: 9px;
  border-radius: 11px; background: var(--blue-soft); border: 1px solid #22364b;
  color: var(--muted); font-size: 11px;
}
.works-strip .ic { width: 15px; height: 15px; color: var(--blue); }
.works-strip b { color: var(--text); font-weight: 600; }
.works-strip .spacer { flex: 1; }
/* Итоговый баннер «Малинки»: цвет состояния вместо синего по умолчанию. */
.works-strip.ok { background: var(--green-soft); border-color: var(--green-line); }
.works-strip.ok .ic { color: var(--green); }
.works-strip.warn { background: var(--amber-soft); border-color: var(--amber-line); }
.works-strip.warn .ic { color: var(--amber); }
.works-strip.fail { background: var(--pink-soft); border-color: var(--pink-line); }
.works-strip.fail .ic { color: var(--pink); }
.works-strip.unknown { background: #171d24; border-color: var(--line-2); }
.works-strip.unknown .ic { color: var(--faint); }
.works-strip .btn { flex: 0 0 auto; }
.worklist { display: flex; flex-direction: column; gap: 7px; }
.work {
  display: block; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; color: var(--text);
}
.work:hover { border-color: var(--line-2); background: #1b2632; }
.work.is-on { border-color: var(--green-line); background: #132520; }
.wtop { display: flex; align-items: center; gap: 7px; min-width: 0; }
.wname { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wmeta { color: var(--muted); font-size: 10px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px 8px; }
.wmeta .sep { color: var(--line-2); }
.works-foot { text-align: center; color: var(--faint); font-size: 10px; padding: 9px 0 2px; }

/* ---------------- работа раскрыта ---------------- */
.work-head { display: flex; align-items: center; gap: 9px; padding: 8px 12px 9px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.work-head .who { flex: 1; min-width: 0; }
.work-head .who b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-head .who span { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-scroll { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px calc(18px + var(--safe-bottom)); }
.wsum { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.wsum > div { flex: 1; min-width: 0; padding: 8px 4px; text-align: center; border-left: 1px solid var(--line); }
.wsum > div:first-child { border-left: 0; }
.wsum b { display: block; font-size: 14px; font-weight: 650; white-space: nowrap; }
.wsum span { display: block; color: var(--muted); font-size: 9px; white-space: nowrap; }
.work-live { display: flex; align-items: center; gap: 7px; margin-top: 9px; padding: 7px 10px; border-radius: 9px; background: var(--blue-soft); border: 1px solid #22364b; color: var(--muted); font-size: 10.5px; }
.work-live b { color: var(--text); font-weight: 600; }
.timeline { padding: 0; margin: 0; list-style: none; }
.step { display: flex; gap: 9px; padding: 4px 0; min-width: 0; }
.rail { width: 12px; flex: 0 0 12px; display: flex; flex-direction: column; align-items: center; }
.rail .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-top: 5px; flex: 0 0 8px; }
.rail .dot.b { background: var(--blue); }
.rail .dot.a { background: var(--amber); }
.rail .dot.p { background: var(--pink); }
.rail .dot.m { background: var(--faint); }
.rail .line { flex: 1; width: 1px; background: var(--line-2); margin: 3px 0 0; }
.step:last-child .line { display: none; }
.sb { flex: 1; min-width: 0; }
.st { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.tool {
  flex: 0 0 auto; font: 600 9px/1.6 var(--mono); color: var(--blue);
  background: #152232; border: 1px solid #24384f; border-radius: 5px; padding: 0 5px;
}
.sact { flex: 1; min-width: 0; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dur { margin-left: auto; flex: 0 0 auto; color: var(--faint); font-size: 9.5px; white-space: nowrap; }
.snote { color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.result-box {
  background: #132a20; border: 1px solid #234a37; border-radius: 10px; padding: 9px 11px;
  font-size: 11.5px; color: #cfe9db; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
}
.result-box.bad { background: var(--pink-soft); border-color: var(--pink-line); color: #ffd3df; }
.artrow {
  display: flex; align-items: center; gap: 9px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px; margin-bottom: 5px; color: var(--text);
}
.artrow .aic { width: 25px; height: 25px; border-radius: 6px; background: #1b2a38; display: grid; place-items: center; color: var(--violet); flex: 0 0 25px; }
.artrow .an { flex: 1; min-width: 0; font-size: 10.8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artrow .as { flex: 0 0 auto; color: var(--muted); font-size: 9px; white-space: nowrap; }
.artrow .ic { width: 14px; height: 14px; }
.work-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.work-actions .btn { flex: 1 1 120px; }
.work-empty { padding: 40px 14px; }

/* ---------------- планы, файлы, дом, ещё ---------------- */
.datebar { display: flex; align-items: center; gap: 10px; padding: 1px 0 8px; }
.datebar b { font-size: 12.5px; font-weight: 600; }
.datebar span { margin-left: auto; color: var(--green); border: 1px solid var(--green-line); background: var(--green-soft); border-radius: 99px; padding: 2px 7px; font-size: 9px; }
.tl { padding: 0; }
.tli { display: flex; gap: 9px; padding: 7px 0; border-bottom: 1px dashed #1c2632; }
.tli:last-child { border-bottom: 0; }
.tlt { width: 42px; flex: 0 0 42px; color: var(--muted); font-size: 11px; padding-top: 1px; }
.tlb { flex: 1; min-width: 0; }
.tlb b { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlb span { display: block; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tldot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex: 0 0 7px; background: var(--blue); }
.card-block { background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; margin-bottom: 8px; }
.cbhead { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 6px; font-weight: 700; }
.cbhead .ic { width: 12px; height: 12px; }
.cbrow { display: flex; align-items: center; gap: 7px; padding: 4px 0; font-size: 11px; min-width: 0; }
.cbrow .ic { width: 13px; height: 13px; color: var(--muted); flex: 0 0 13px; }
.cbrow .txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbrow .r { margin-left: auto; color: var(--faint); font-size: 9.5px; flex: 0 0 auto; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px;
  color: var(--text); min-width: 0;
}
.tile:hover { border-color: var(--line-2); background: var(--panel-3); }
.tile .ti { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; margin-bottom: 4px; }
.tile .ti .ic { width: 14px; height: 14px; }
.ti.b { background: #152232; color: var(--blue); } .ti.g { background: #12251d; color: var(--green); }
.ti.a { background: #241c10; color: var(--amber); } .ti.v { background: #1e1729; color: var(--violet); }
.ti.p { background: #241318; color: var(--pink); }
.tile b { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile span { color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.profile-card { display: flex; align-items: center; gap: 10px; padding: 11px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.profile-card .pav { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(140deg, var(--violet), var(--blue)); display: grid; place-items: center; color: #0a1220; font-weight: 700; flex: 0 0 40px; }
.profile-card b { display: block; font-size: 13px; font-weight: 600; }
.profile-card span { display: block; color: var(--muted); font-size: 10px; }
.profile-card .chev { margin-left: auto; color: var(--faint); }
.file-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px dashed #1c2632; color: var(--text); min-width: 0; }
.file-row:last-child { border-bottom: 0; }
.file-row .aic { width: 30px; height: 30px; border-radius: 8px; background: #1b2a38; display: grid; place-items: center; color: var(--blue); flex: 0 0 30px; }
.file-row .an { flex: 1; min-width: 0; }
.file-row .an b { display: block; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .an span { display: block; color: var(--faint); font-size: 9.5px; }
.file-row .as { flex: 0 0 auto; color: var(--faint); font-size: 9.5px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; min-width: 0; }
.stat .sl { color: var(--faint); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.stat .sv { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sv .ok { color: var(--green); font-size: 9.5px; }
.stat .sv .warn, .stat .sv .bad { font-size: 9.5px; }
.stat .ss { color: var(--muted); font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 5px 0; border-bottom: 1px dashed #1e2833; min-width: 0; }
.srow:last-child { border-bottom: 0; }
.srow .k { color: var(--muted); flex: 0 0 auto; }
.srow .v { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ok { color: var(--green); } .warn { color: var(--amber); } .bad { color: var(--pink); }

/* ---------------- полная версия: состояния, строки, формы ---------------- */
.badge {
  display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap;
  border: 1px solid var(--line-2); border-radius: 99px; padding: 2px 7px;
  font-size: 9px; font-weight: 700; letter-spacing: .02em; color: var(--muted); background: #171d24;
}
.badge.ok { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.badge.warn { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.badge.fail { color: var(--pink); border-color: var(--pink-line); background: var(--pink-soft); }
.badge.unknown { color: var(--muted); border-color: var(--line-2); background: #171d24; }
.badge.info { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }

.admin-item { padding: 7px 0; border-top: 1px dashed #1e2833; min-width: 0; }
.admin-item:first-child { border-top: 0; padding-top: 2px; }
.admin-item .head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.admin-item .head .txt {
  flex: 1; min-width: 0; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-item .meta { display: flex; flex-wrap: wrap; gap: 1px 7px; color: var(--faint); font-size: 9.8px; margin-top: 2px; overflow-wrap: anywhere; }
.admin-item .meta .sep { color: var(--line-2); }
.actions-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.card-block > .actions-row { margin: 0 0 7px; }
.actions-row .btn { min-height: 28px; padding: 0 9px; font-size: 10.5px; }

.token-box {
  margin: 8px 0 4px; padding: 10px 11px; border-radius: 10px;
  background: #0f1720; border: 1px solid var(--green-line);
  color: var(--green); font: 12px/1.5 var(--mono);
  word-break: break-all; overflow-wrap: anywhere;
}
.token-box code { font: inherit; color: inherit; }

.form-grid { display: grid; gap: 10px; }
.form-grid .field { margin-bottom: 0; }

.srcitem + .srcitem { border-top: 1px dashed #1e2833; margin-top: 2px; }
.srcitem { padding: 3px 0; }
.cbhead .count { margin-left: auto; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--faint); }
.denied { max-width: 420px; margin: 30px auto; text-align: center; }
.denied .ic { width: 30px; height: 30px; color: var(--faint); margin-bottom: 6px; }
.denied b { display: block; font-size: 14px; margin-bottom: 4px; }
.denied span { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 10px; }

/* ---------------- модалка и тост ---------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 10, .72); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(100%, 460px); max-height: min(86dvh, 720px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px 10px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 650; }
.modal-body { padding: 13px 14px 16px; overflow: auto; }
.modal-body textarea { width: 100%; min-height: 110px; resize: vertical; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); padding: 10px 12px; color: var(--text); font-size: 13px; line-height: 1.45; }
.modal-body textarea:focus { outline: none; border-color: var(--blue); }
.modal-actions { display: flex; gap: 8px; margin-top: 11px; }
.modal-actions .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 18px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 80; max-width: min(92vw, 460px); background: #1b2632; border: 1px solid var(--line-2);
  color: var(--text); border-radius: 11px; padding: 9px 13px; font-size: 12px; box-shadow: var(--shadow);
}
.toast.bad { border-color: var(--pink-line); color: #ffd3df; }
.toast.ok { border-color: var(--green-line); color: #c9f5e1; }

/* ---------------- планшет и десктоп ---------------- */
@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page { padding: 20px 20px 30px; }
}

@media (min-width: 900px) {
  .brand-top .brand-name { display: inline; }
  .chats-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .chat-main { display: flex; }
  .chatlist-pane { border-right: 1px solid var(--line); }
  .main { padding-bottom: 0; }
  .tabbar { display: none; }
  body[data-detail="1"] .tabbar { display: none; }
  .chat-body { padding: 12px 18px 16px; }
  .composer { padding-bottom: 10px; }
  .work-head { padding: 10px 18px 11px; }
  .work-scroll { padding: 12px 18px 24px; }
  .chat-head { padding: 8px 16px 9px; }
  .toast { bottom: 22px; }
  .datebar b { font-size: 13.5px; }
}

@media (min-width: 1024px) {
  .topbar { gap: 16px; padding: 0 18px; }
  .pagehead { display: none; }
  .mainnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; margin-left: 6px; }
  .navlink {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px;
    border-radius: 9px; color: var(--muted); font-size: 11.5px; white-space: nowrap;
  }
  .navlink .ic { width: 15px; height: 15px; }
  .navlink:hover { color: var(--text); background: #141c25; }
  .navlink.on { color: var(--green); background: #16261f; }
  .top-actions { margin-left: 0; }
}

@media (min-width: 1280px) {
  .chats-layout { grid-template-columns: 300px minmax(0, 1fr) 312px; }
  .agent-pane { display: block; }
}

@media (max-width: 1279px) {
  .navlink.admin { display: none; }
}

@media (max-width: 1023px) {
  /* На телефоне заголовок уже есть в верхней панели — не дублируем его. */
  .page-head { display: none; }
  .page { padding-top: 10px; }
  .chatlist-pane .pane-title { display: none; }
  .chatlist-pane .pane-head { padding-top: 8px; }
}

@media (max-width: 899px) {
  body[data-detail="1"] .topbar { display: none; }
  body[data-detail="1"] .chat-head,
  body[data-detail="1"] .work-head { padding-top: calc(7px + var(--safe-top)); }
  body[data-mobile-page="chat"] .chatlist-pane { display: none; }
  body[data-mobile-page="chat"] .chat-main { display: flex; }
  body[data-mobile-page="chat"] .main { padding-bottom: 0; }
  body[data-mobile-page="chat"] .chat-list-back { display: grid; }
}
@media (min-width: 900px) {
  .chat-list-back { display: none !important; }
}
@media (max-width: 360px) {
  .topbar { padding: var(--safe-top) 8px 0; gap: 6px; }
  .icon-btn { width: 32px; height: 32px; flex-basis: 32px; }
  .chatrow { gap: 8px; padding: 7px 6px; }
  .cav { width: 38px; height: 38px; flex-basis: 38px; }
  .tabbtn { font-size: 9px; }
  .page { padding-left: 10px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------- вложения в чате /app (PLB-051) ---------------- */
.composer.composer-stack { flex-direction: column; align-items: stretch; gap: 6px; }
.composer-row { display: flex; gap: 7px; align-items: flex-end; width: 100%; }
.attach-input { display: none; }
.attachbtn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2);
  border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--muted); flex: 0 0 36px; cursor: pointer;
}
.attachbtn:hover { color: var(--text); border-color: var(--line-2); }
.attachbtn .ic { width: 17px; height: 17px; }
.attach-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.attach-bar::-webkit-scrollbar { display: none; }
.attach-bar[hidden] { display: none; }
.attach-item {
  display: flex; align-items: center; gap: 7px; max-width: 220px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 5px 6px; flex: 0 0 auto;
}
.attach-item.bad { border-color: var(--pink-line); }
.attach-item img.athumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: 0 0 34px; }
.attach-item .afile { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: #1b2530; color: var(--muted); flex: 0 0 34px; }
.attach-item .ameta { min-width: 0; display: flex; flex-direction: column; }
.attach-item .ameta b { font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-item .ameta span { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-item.bad .ameta span { color: var(--pink); }
.attach-item .ax {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); background: transparent; border: 0; flex: 0 0 22px; cursor: pointer;
}
.attach-item .ax:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.attach-item .ax .ic { width: 13px; height: 13px; }
@media (max-width: 560px) {
  .attach-item { max-width: 160px; }
  .attach-item .ameta b { font-size: 10px; }
}

/* NAS: строки файлов и честные статусы. */
.listrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.listrow:last-child { border-bottom: 0; }
.linkbtn { background: transparent; border: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer; padding: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbtn:hover { color: var(--blue); }
.note.ok { color: var(--green); }
.note.bad { color: var(--pink); }
.notes { margin: 6px 0 0 18px; padding: 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }

/* Моноширинный предпросмотр: письмо, дайджест, текст документа. */
.pre { white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; max-height: 60vh; overflow: auto; }
