/* Мессенджер СЦ «Точка» — мягкий футуризм.
   Глубокий фон с аврорами, стеклянные поверхности, пастельные акценты. */

:root {
  --bg-0: #080b16;
  --bg-1: #0d1122;
  --bg-2: #131831;
  --bg-3: #1a2040;
  --line: rgba(168, 180, 220, .13);
  --line-soft: rgba(168, 180, 220, .08);
  --text: #eef1fb;
  --text-dim: #aeb7d4;
  --text-faint: #7f89ab;
  --accent: #9b8cff;
  --accent-2: #6fd6ff;
  --accent-3: #8ef0c8;
  --rose: #ffb3c7;
  --ok: #6ee7b7;
  --warn: #f7c978;
  --danger: #ff8f9b;
  --accent-soft: rgba(155, 140, 255, .16);
  --glass: linear-gradient(180deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  --glass-strong: linear-gradient(180deg, rgba(255, 255, 255, .09), rgba(255, 255, 255, .03));
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(4, 6, 18, .55);
  --glow: 0 0 46px rgba(155, 140, 255, .18);
  --sidebar-w: 328px;
  --font: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont,
          "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(48% 42% at 12% 8%, rgba(155, 140, 255, .26), transparent 62%),
    radial-gradient(44% 40% at 88% 4%, rgba(111, 214, 255, .18), transparent 60%),
    radial-gradient(52% 46% at 74% 96%, rgba(142, 240, 200, .12), transparent 64%),
    radial-gradient(40% 36% at 26% 92%, rgba(255, 179, 199, .1), transparent 60%);
  filter: blur(10px);
  animation: aurora 26s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 1.5%, 0) scale(1.06); }
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-dim); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ */
/* Вход                                                                */
/* ------------------------------------------------------------------ */
.login-wrap, .splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow: auto;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 30px;
  box-shadow: var(--shadow), var(--glow);
  backdrop-filter: blur(26px) saturate(120%);
  animation: rise .45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.brand { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.logo {
  width: 54px; height: 54px; flex: 0 0 54px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 24px;
  color: #0b0e1a;
  background: linear-gradient(140deg, var(--accent-2), var(--accent) 55%, var(--rose));
  box-shadow: 0 10px 34px rgba(155, 140, 255, .38), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -.3px; font-weight: 650; }
.brand p { margin: 3px 0 0; font-size: 13px; color: var(--text-faint); }

label {
  display: block; font-size: 12.5px; color: var(--text-dim);
  margin: 16px 0 7px; letter-spacing: .01em;
}
input, textarea, select {
  width: 100%;
  background: rgba(8, 11, 22, .55);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus {
  border-color: rgba(155, 140, 255, .55);
  background: rgba(8, 11, 22, .72);
  box-shadow: 0 0 0 4px rgba(155, 140, 255, .14);
}
select option { background: var(--bg-2); }

.btn {
  border: 1px solid var(--line);
  background: var(--glass-strong);
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform .12s, filter .15s, border-color .15s, background .15s;
}
.btn:hover { filter: brightness(1.12); border-color: rgba(168, 180, 220, .28); }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 58%, var(--rose));
  color: #0a0d18;
  border: none;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(155, 140, 255, .32);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-block { width: 100%; margin-top: 22px; padding: 13px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.btn-danger {
  background: rgba(255, 143, 155, .12);
  border-color: rgba(255, 143, 155, .35);
  color: #ffc2c8;
}
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.link {
  background: none; border: none; color: var(--accent-2);
  cursor: pointer; padding: 0; font-size: 13px;
}
.link:hover { text-decoration: underline; }
.form-error { color: #ffb0b9; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.login-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }

.splash { flex-direction: column; gap: 18px; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .08);
  border-top-color: var(--accent-2);
  border-right-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ */
/* Каркас                                                              */
/* ------------------------------------------------------------------ */
#app { display: flex; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(19, 24, 49, .82), rgba(8, 11, 22, .9));
  border-right: 1px solid var(--line-soft);
  backdrop-filter: blur(22px) saturate(115%);
  position: relative;
}
.sidebar::after {
  content: "";
  position: absolute; top: 0; right: -1px; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(155, 140, 255, .45), transparent);
  opacity: .5;
}
.side-head { padding: 20px 16px 12px; }
.side-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.side-brand .logo {
  width: 38px; height: 38px; flex-basis: 38px; font-size: 17px; border-radius: 13px;
}
.side-brand h1 { font-size: 15px; margin: 0; letter-spacing: -.2px; }
.side-brand p { margin: 1px 0 0; font-size: 11.5px; color: var(--text-faint); }
.side-actions { display: flex; gap: 8px; }
.search-row { display: flex; gap: 8px; margin-top: 12px; }
.search-row input { padding: 10px 13px; font-size: 13.5px; border-radius: 999px; }

.self-card {
  display: flex; align-items: center; gap: 11px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--glass);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.self-card:hover { border-color: rgba(155, 140, 255, .35); transform: translateY(-1px); }
.self-meta { min-width: 0; flex: 1; }
.self-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-sub { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-list { flex: 1; overflow-y: auto; padding: 8px 8px 14px; }
.chat-list h2 {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-faint); margin: 16px 12px 7px; font-weight: 600;
}
.chat-item {
  position: relative;
  display: flex; gap: 11px; align-items: center;
  padding: 10px 11px;
  border-radius: 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .15s;
}
.chat-item:hover { background: rgba(255, 255, 255, .045); }
.chat-item.active {
  background: linear-gradient(135deg, rgba(155, 140, 255, .18), rgba(111, 214, 255, .07));
  border-color: rgba(155, 140, 255, .3);
}
.chat-item.active::before {
  content: "";
  position: absolute; left: -8px; top: 16px; bottom: 16px; width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 12px rgba(155, 140, 255, .7);
}
.chat-item .body { min-width: 0; flex: 1; }
.chat-item .top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item .name {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item .time { font-size: 10.5px; color: var(--text-faint); flex: 0 0 auto; margin-top: 2px; }
.chat-item .preview {
  font-size: 12.5px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #0a0d18; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(111, 214, 255, .3);
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint); position: absolute; right: -1px; bottom: -1px;
  border: 2px solid var(--bg-1);
}
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(110, 231, 183, .8); }

.avatar {
  position: relative;
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 15px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  color: #fff;
  background-color: #5b6cff;
  background-image: linear-gradient(145deg, rgba(255, 255, 255, .26), rgba(0, 0, 0, .28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 18px rgba(4, 6, 18, .35);
  user-select: none;
}
.avatar.sm { width: 34px; height: 34px; flex-basis: 34px; font-size: 13px; border-radius: 12px; }
.avatar.lg { width: 68px; height: 68px; flex-basis: 68px; font-size: 25px; border-radius: 22px; }

/* ------------------------------------------------------------------ */
/* Чат                                                                 */
/* ------------------------------------------------------------------ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.main::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 45% at 80% 0%, rgba(111, 214, 255, .07), transparent 60%),
    radial-gradient(50% 40% at 10% 100%, rgba(155, 140, 255, .07), transparent 60%);
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(13, 17, 34, .62);
  backdrop-filter: blur(18px);
  min-height: 68px;
  z-index: 2;
}
.chat-head .title { font-size: 15px; font-weight: 650; letter-spacing: -.1px; }
.chat-head .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head .title, .chat-head .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: transparent; border: none; color: var(--text-dim);
  cursor: pointer; padding: 6px 8px; border-radius: 11px; line-height: 1;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.icon-btn.danger:hover { color: #ffb0b9; background: rgba(255, 143, 155, .12); }

.messages {
  flex: 1; overflow-y: auto;
  padding: 20px clamp(12px, 4vw, 52px) 10px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}
.messages-inner { max-width: 900px; margin: 0 auto; }

.day-sep {
  display: flex; align-items: center; gap: 12px;
  font-size: 11px; color: var(--text-faint);
  margin: 20px 0 10px;
}
.day-sep::before, .day-sep::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}
.msg { display: flex; gap: 10px; margin: 10px 0; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } }
.msg .avatar { align-self: flex-end; }
.msg .bubble-wrap { max-width: min(680px, 82%); }
.msg .meta {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 11.5px; color: var(--text-faint); margin-bottom: 4px; padding: 0 6px;
}
.msg .author { font-weight: 650; color: var(--text-dim); }
.msg .role-bot { color: var(--accent-3); font-weight: 700; }
.bubble {
  background: var(--glass);
  border: 1px solid var(--line-soft);
  border-radius: 6px 18px 18px 18px;
  padding: 11px 14px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 24px rgba(3, 5, 14, .28);
}
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble-wrap { text-align: right; }
.msg.mine .meta { justify-content: flex-end; }
.msg.mine .bubble {
  background: linear-gradient(140deg, rgba(155, 140, 255, .26), rgba(111, 214, 255, .14));
  border-color: rgba(155, 140, 255, .34);
  border-radius: 18px 6px 18px 18px;
  text-align: left;
}
.msg .bubble code {
  background: rgba(0, 0, 0, .28); padding: 2px 6px; border-radius: 7px;
  font-family: var(--mono); font-size: 12.5px;
}
.msg .bubble a { color: #a9e7ff; }
.msg .bubble .mention { color: var(--accent-2); font-weight: 650; }
.msg.optimistic { opacity: .55; }
.msg .attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.msg .attachments img {
  max-width: 330px; max-height: 250px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(3, 5, 14, .35);
}
.msg .file-chip {
  display: inline-flex; gap: 8px; align-items: center;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 9px 12px; font-size: 12.5px;
  text-decoration: none; color: var(--text);
  transition: border-color .15s;
}
.msg .file-chip:hover { border-color: rgba(155, 140, 255, .45); text-decoration: none; }
.reply-quote {
  border-left: 3px solid var(--accent-2);
  background: rgba(0, 0, 0, .22);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 7px;
  font-size: 12px; color: var(--text-dim);
}
.reply-quote b { color: var(--text); }
.msg-actions { opacity: 0; transition: opacity .15s; display: flex; gap: 2px; align-items: center; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }

.typing-line {
  min-height: 20px; font-size: 11.5px; color: var(--text-faint);
  padding: 0 clamp(12px, 4vw, 52px) 4px; position: relative; z-index: 1;
}
.typing-line .dots::after { content: "…"; animation: blink 1.2s infinite steps(3); }
@keyframes blink { 50% { opacity: .3; } }

/* ------------------------------------------------------------------ */
/* Ввод                                                                */
/* ------------------------------------------------------------------ */
.composer {
  position: relative; z-index: 2;
  padding: 10px clamp(12px, 4vw, 52px) calc(14px + env(safe-area-inset-bottom));
}
.composer-inner { max-width: 900px; margin: 0 auto; }
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  background: rgba(19, 24, 49, .8);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; font-size: 12.5px;
  backdrop-filter: blur(12px);
}
.reply-bar .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attach-chip {
  display: inline-flex; gap: 8px; align-items: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line-soft);
  border-radius: 11px; padding: 6px 10px; font-size: 12px;
}
.composer-row {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 6px 6px 6px 12px;
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px rgba(3, 5, 14, .35);
}
.composer-row:focus-within { border-color: rgba(155, 140, 255, .4); }
.composer-row textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 180px;
  padding: 10px 6px; border: none; background: transparent; box-shadow: none;
  line-height: 1.4;
}
.composer-row textarea:focus { box-shadow: none; }
.send-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  border-radius: 15px; border: none; cursor: pointer;
  background: linear-gradient(140deg, var(--accent-2), var(--accent));
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(111, 214, 255, .28);
  transition: transform .12s, filter .15s;
}
.send-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.send-btn svg { width: 19px; height: 19px; fill: none; stroke: #0a0d18; stroke-width: 2.2; }

.empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-faint); text-align: center; padding: 32px;
  position: relative; z-index: 1;
}
.empty h2 { color: var(--text-dim); font-size: 18px; margin: 0; font-weight: 600; }
.empty .logo { width: 76px; height: 76px; font-size: 30px; border-radius: 24px; }

/* ------------------------------------------------------------------ */
/* Модальные окна                                                      */
/* ------------------------------------------------------------------ */
.modal-back {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 6, 16, .62);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(27, 33, 64, .96), rgba(13, 17, 34, .98));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow), var(--glow);
  padding: 24px;
  animation: pop .2s cubic-bezier(.2, .8, .2, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }
.modal h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.2px; }
.modal .sub { margin: 0 0 16px; font-size: 13px; color: var(--text-dim); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; margin-top: 10px; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border: 1px solid var(--line-soft);
  border-radius: 14px; background: rgba(255, 255, 255, .035);
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name { font-size: 13.5px; }
.list-item .hint { font-size: 11.5px; color: var(--text-faint); }
.check { display: flex; align-items: center; gap: 9px; padding: 7px 4px; font-size: 13.5px; color: var(--text); }
.check input { width: auto; accent-color: var(--accent); }
.tag {
  font-size: 10.5px; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--text-dim); border: 1px solid var(--line);
  white-space: nowrap;
}
.tag.admin { color: #ffe0a3; border-color: rgba(247, 201, 120, .35); }
.tag.manager { color: #b9e8ff; border-color: rgba(111, 214, 255, .35); }
.tag.bot { color: #d8ccff; border-color: rgba(155, 140, 255, .4); }

.tabs { display: flex; gap: 7px; flex-wrap: wrap; margin: 14px 0 8px; }
.tab {
  background: rgba(255, 255, 255, .045);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 999px; padding: 7px 13px; cursor: pointer; font-size: 12px;
  transition: all .15s;
}
.tab:hover { color: var(--text); border-color: rgba(155, 140, 255, .3); }
.tab.active {
  background: linear-gradient(135deg, rgba(155, 140, 255, .24), rgba(111, 214, 255, .12));
  color: var(--text); border-color: rgba(155, 140, 255, .45);
}

.toast-wrap {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: rgba(27, 33, 64, .94);
  border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 16px; font-size: 13px;
  box-shadow: var(--shadow); animation: rise .2s ease-out;
  backdrop-filter: blur(14px);
}
.toast.err { border-color: rgba(255, 143, 155, .45); color: #ffc2c8; }

/* ------------------------------------------------------------------ */
/* Заявки                                                              */
/* ------------------------------------------------------------------ */
.order-card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  text-align: left;
  min-width: 280px;
  box-shadow: 0 12px 34px rgba(3, 5, 14, .3);
}
.order-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.order-title { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.order-row { font-size: 12.5px; margin: 4px 0; color: var(--text); }
.order-row .muted { margin-right: 5px; }
.order-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.order-docs { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.order-card .attachments img { max-width: 128px; max-height: 96px; border-radius: 12px; }
.order-group { margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.order-group > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.order-group > summary .muted { font-weight: 400; margin-left: 6px; }
.order-slots { margin-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.order-slot { border: 1px solid var(--line-soft); border-radius: 14px; padding: 9px 11px; background: rgba(255, 255, 255, .02); }
.order-slot-head { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.order-slot-head .muted { font-size: 11.5px; }
.order-slot-head button { margin-left: auto; padding: 4px 11px; }
.slot-empty { font-size: 11.5px; margin-top: 5px; }
.order-files { margin-top: 10px; border-top: 1px solid var(--line-soft); padding-top: 9px; }
.order-files-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 7px; font-size: 13px; }
.order-file {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 11px; background: rgba(0, 0, 0, .18);
  margin: 4px 0; font-size: 12.5px;
}
.order-file-icon { flex: 0 0 18px; text-align: center; }
.order-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.order-file-size { flex: 0 0 auto; font-size: 11px; }
.order-file .icon-btn { opacity: .55; }
.order-file:hover .icon-btn { opacity: 1; }

.offline-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: linear-gradient(135deg, rgba(247, 201, 120, .95), rgba(255, 179, 199, .9));
  color: #1a1305;
  font-size: 12.5px; text-align: center; padding: 8px 12px;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Скроллбары                                                          */
/* ------------------------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: rgba(155, 140, 255, .35) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(155, 140, 255, .45), rgba(111, 214, 255, .35));
  border-radius: 999px; border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(155, 140, 255, .6); background-clip: content-box; }

/* ------------------------------------------------------------------ */
/* Телефон                                                             */
/* ------------------------------------------------------------------ */
.mobile-back { display: none; }
@media (max-width: 860px) {
  :root { --sidebar-w: 100%; }
  .sidebar { position: absolute; inset: 0; z-index: 20; }
  #app.chat-open .sidebar { display: none; }
  #app:not(.chat-open) .main { display: none; }
  .mobile-back { display: grid; }
  .chat-head { padding: 11px 13px; }
  .messages { padding: 14px 10px 4px; }
  .msg .bubble-wrap { max-width: 88%; }
  .composer { padding: 8px 10px calc(12px + env(safe-area-inset-bottom)); }
  .composer-row { border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
  body::before { animation: none; }
}

/* Заявка строками прямо в чате */
.order-lines { margin-top: 6px; display: flex; flex-direction: column; }
.order-line {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px dashed rgba(168, 180, 220, .1);
  font-size: 12.5px;
  cursor: text;
}
.order-line:last-child { border-bottom: none; }
.order-line-name { color: var(--text-faint); flex: 0 0 44%; }
.order-line-value { flex: 1; font-weight: 500; word-break: break-word; }
.order-line.empty .order-line-value { color: var(--text-faint); font-weight: 400; }
.order-line:hover { background: rgba(255, 255, 255, .03); border-radius: 8px; }
.order-line-editor {
  flex: 1; padding: 5px 8px; border-radius: 9px;
  border: 1px solid rgba(155, 140, 255, .5);
  background: rgba(8, 11, 22, .8); font-size: 12.5px;
}
.order-line.slot { align-items: center; cursor: default; }
.order-line-files { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.order-file-inline {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 3px 7px; font-size: 11.5px;
}
.order-group-title {
  margin: 12px 0 4px; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-faint);
}
.order-composer {
  display: flex; align-items: center; gap: 9px;
  margin: 10px clamp(12px, 4vw, 52px);
  padding: 9px 12px;
  background: var(--glass);
  border: 1px solid rgba(155, 140, 255, .35);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(3, 5, 14, .3);
}
.order-composer input { flex: 1; border-radius: 10px; padding: 8px 11px; }

/* Кабинет инженера внутри приложения */
.engineer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: radial-gradient(60% 50% at 20% 0%, rgba(155, 140, 255, .18), transparent 60%),
              radial-gradient(50% 40% at 90% 100%, rgba(111, 214, 255, .12), transparent 60%),
              #0a0d18;
  display: flex; flex-direction: column;
  animation: rise .25s ease-out;
}
.engineer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(13, 17, 34, .8);
  backdrop-filter: blur(16px);
}
.engineer-head .muted { flex: 1; font-size: 12px; }
.engineer-frame {
  flex: 1; width: 100%; border: none; background: #0a0d18;
}

/* выравнивание строк заявки и карточек */
.order-card { max-width: 100%; }
.order-line { align-items: flex-start; }
.order-line-name { flex: 0 1 44%; min-width: 130px; }
.order-line-value { min-width: 0; }
.order-line-files { min-width: 0; }
.msg .bubble-wrap { min-width: 0; }
#ui-version { color: var(--accent-2); font-weight: 600; }

/* шапка сайдбара: ровно в одну строку */
.side-brand { flex-wrap: nowrap; align-items: center; }
.side-brand .grow { min-width: 0; flex: 1; }
.side-brand h1 {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 14px; max-width: 100%;
}
.side-brand p {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 11px;
}
.side-brand .icon-btn { flex: 0 0 auto; }

.bubble-text { white-space: pre-wrap; }
.bubble > .reply-quote { white-space: normal; }

.ver {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent-2); border: 1px solid rgba(111, 214, 255, .35);
  border-radius: 999px; padding: 1px 5px; vertical-align: 2px;
  margin-left: 4px;
}

.order-line { flex-wrap: nowrap; flex-direction: row; gap: 12px; }
.order-line-name { flex: 0 0 44%; min-width: 0; }
.order-line-value { flex: 1 1 auto; min-width: 0; text-align: left; }
.order-line.slot .order-line-name { flex: 0 0 44%; }

/* прокрутка: колонка сообщений получает ограничение по высоте */
#app { min-height: 0; }
.main { min-height: 0; overflow: hidden; }
#chat-view { min-height: 0; }
.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.chat-list { min-height: 0; }

/* видимый бегунок справа */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, .03); border-radius: 999px; }
::-webkit-scrollbar-thumb {
  background: rgba(155, 140, 255, .55);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(155, 140, 255, .8); background-clip: content-box; }

/* высота окна: fallback для браузеров без dvh */
#app { height: 100vh; height: 100dvh; }
/* всегда видимая полоса прокрутки ленты */
.messages {
  overflow-y: scroll;
  scroll-behavior: auto;
  scrollbar-width: auto;
}

/* собственный бегунок справа */
.messages { scrollbar-width: none; }
.messages::-webkit-scrollbar { width: 0; height: 0; display: none; }
.scroll-rail {
  position: absolute; right: 6px; top: 82px; bottom: 96px; width: 7px;
  border-radius: 999px; background: rgba(255, 255, 255, .05);
  z-index: 3;
}
.scroll-thumb {
  position: absolute; left: 0; top: 0; width: 100%; min-height: 38px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(155, 140, 255, .85), rgba(111, 214, 255, .7));
  box-shadow: 0 0 12px rgba(155, 140, 255, .45);
  cursor: grab;
}
.scroll-thumb:active { cursor: grabbing; }
@media (max-width: 860px) { .scroll-rail { top: 70px; bottom: 86px; right: 3px; } }

/* блоки оборудования в заявке */
.order-blocks { margin-top: 12px; }
.order-block {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 8px 10px;
  margin: 8px 0;
  background: rgba(255, 255, 255, .025);
}
.order-block-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; margin-bottom: 4px;
}
.order-block .order-line { padding: 4px 0; }
.order-block + .btn { margin-top: 6px; }

/* ежедневная проверка */
.checkin-card {
  margin: 4px 10px 8px;
  padding: 10px 12px;
  border: 1px solid rgba(111, 214, 255, .3);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(111, 214, 255, .1), rgba(155, 140, 255, .08));
  max-height: 46vh; overflow-y: auto;
}
.checkin-title { font-size: 13px; font-weight: 650; margin-bottom: 2px; }
.checkin-list { margin: 8px 0; display: flex; flex-direction: column; gap: 3px; }
.checkin-list .check { font-size: 12px; padding: 3px 0; align-items: flex-start; }
.checkin-list .check input { margin-top: 3px; }
#checkin-note { padding: 7px 9px; font-size: 12px; border-radius: 9px; margin-bottom: 8px; }

/* журнал и рекомендации */
.journal { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.journal-entry {
  border-left: 2px solid rgba(111, 214, 255, .45);
  padding: 4px 8px; margin: 6px 0; font-size: 12.5px;
  background: rgba(255, 255, 255, .02); border-radius: 6px;
}
.journal-meta { font-size: 10.5px; color: var(--text-faint); margin-bottom: 2px; }
.journal-decision { color: var(--accent-3); font-size: 11.5px; margin-top: 3px; }
.journal-input {
  width: 100%; margin-top: 8px; min-height: 54px; font-size: 12.5px;
  border-radius: 10px; padding: 8px 10px;
}
.advice-card {
  margin-top: 10px; padding: 10px 12px;
  border: 1px solid rgba(155, 140, 255, .35);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(155, 140, 255, .12), rgba(111, 214, 255, .05));
}
.advice-head { font-weight: 650; margin-bottom: 6px; }
.advice-card ol { margin: 0 0 8px 18px; padding: 0; font-size: 12.5px; }
.advice-card li { margin: 3px 0; }
.advice-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }

/* вкладка «Бортовой журнал» */
.journal-overlay {
  position: fixed; inset: 0; z-index: 95;
  background: radial-gradient(60% 50% at 20% 0%, rgba(155, 140, 255, .16), transparent 60%),
              #0a0d18;
  display: flex; flex-direction: column;
}
.journal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  background: rgba(13, 17, 34, .8);
}
.journal-head b { white-space: nowrap; }
.journal-head input { flex: 1; max-width: 520px; padding: 8px 12px; font-size: 13px; }
.journal-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; }
.journal-prep {
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 14px;
}
.journal-prep-title { font-weight: 650; margin-bottom: 8px; }
.journal-prep-row { display: flex; gap: 8px; flex-wrap: wrap; }
.journal-prep-row input { flex: 1; min-width: 200px; padding: 9px 11px; font-size: 13px; }
.prep-result { margin-top: 8px; }
.journal-list { display: flex; flex-direction: column; gap: 8px; max-width: 980px; }
.journal-row {
  border: 1px solid var(--line-soft); border-radius: 12px;
  padding: 9px 12px; background: rgba(255, 255, 255, .03);
  cursor: pointer; font-size: 13px;
}
.journal-row:hover { border-color: rgba(155, 140, 255, .35); }
.journal-row-top { display: flex; gap: 10px; align-items: baseline; margin-bottom: 3px; flex-wrap: wrap; }
.journal-row-top .muted { font-size: 11px; }
.advice-prep { margin-top: 5px; font-size: 12.5px; color: var(--accent-3); }

/* установка приложения */
.install-btn { width: 100%; margin-bottom: 8px; }
@media (display-mode: standalone) {
  .install-btn { display: none !important; }
}
/* мобильные отступы под вырез экрана */
@supports (padding: env(safe-area-inset-top)) {
  .sidebar-head { padding-top: calc(10px + env(safe-area-inset-top)); }
  .chat-head { padding-top: calc(8px + env(safe-area-inset-top)); }
}

/* мобильная ширина: ничего не выезжает за экран */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  .sidebar { width: 100%; max-width: 100vw; overflow-x: hidden; }
  .chat-list, .chat-list-inner { overflow-x: hidden; }
  .search-row { width: 100%; }
  .search-row input { flex: 1 1 auto; min-width: 0; width: auto; }
  .search-row .btn { flex: 0 0 auto; }
  .chat-item, .chat-item .body { min-width: 0; }
  .chat-item .body { overflow: hidden; }
  .side-brand h1 { max-width: calc(100vw - 200px); }
  .messages { padding-left: 10px; padding-right: 12px; }
  .order-card { min-width: 0; }
  .order-line-name { flex: 0 0 46%; }
  .order-line-value { overflow-wrap: anywhere; }
}

@media (max-width: 860px) {
  .sidebar, .sidebar-head, .chat-list, .search-row { max-width: 100vw; }
  .sidebar-head { padding-left: 14px; padding-right: 14px; }
  .search-row { display: flex; overflow: hidden; gap: 6px; }
  .search-row input {
    flex: 1 1 0; width: 0; min-width: 0; max-width: none;
  }
  .search-row .btn { flex: 0 0 38px; width: 38px; padding: 0; }
  .chat-list { padding-left: 10px; padding-right: 6px; }
  .chat-item { max-width: 100%; }
  .chat-item .body { flex: 1 1 0; width: 0; min-width: 0; overflow: hidden; }
  .chat-item .top { min-width: 0; }
  .chat-item .name { min-width: 0; }
}

/* автодополнение @ в композере */
.composer-inner { position: relative; }
.mention-list {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px);
  max-height: 260px; overflow-y: auto; z-index: 30;
  background: #11162b; border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.mention-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.mention-item.active, .mention-item:hover { background: rgba(155,140,255,.16); }
.mention-avatar {
  width: 24px; height: 24px; border-radius: 8px; flex: 0 0 24px;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff;
}
.mention-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-login { font-size: 11px; color: var(--text-faint); }

.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

.order-file-block { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.file-comment { font-size: 11.5px; padding: 4px 7px; border-radius: 7px; border: 1px solid var(--line-soft); background: rgba(255,255,255,.04); color: var(--text-dim); }

/* панель документации GCC */
.docs-overlay {
  position: fixed; inset: 0; z-index: 96;
  background: radial-gradient(60% 50% at 20% 0%, rgba(111,214,255,.12), transparent 60%), #0a0d18;
  display: flex; flex-direction: column;
}
.docs-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.docs-head input { flex: 1; max-width: 460px; padding: 8px 12px; font-size: 13px; }
.docs-body { flex: 1; overflow-y: auto; padding: 14px 18px 24px; }
.docs-model { margin-bottom: 14px; }
.docs-model-name { font-weight: 650; margin-bottom: 6px; }
.docs-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 10px; border: 1px solid var(--line-soft); border-radius: 10px;
  margin-bottom: 6px; font-size: 13px;
}
.docs-kind { color: var(--accent-2); min-width: 170px; }
.docs-file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-thumb {
  width: 28px; height: 28px; object-fit: cover;
  border-radius: 7px; vertical-align: middle; margin-right: 4px;
}
.side-tabs { display:flex; gap:6px; padding:8px 12px 0; }
.side-tab { flex:1; background:transparent; border:1px solid var(--line); color:var(--muted);
  border-radius:9px; padding:7px 6px; font-size:11.5px; cursor:pointer; }
.side-tab.active { background:var(--accent-soft); color:var(--text); border-color:var(--accent); }
.cabinet { flex:1; overflow-y:auto; padding:26px 30px 40px; display:block; }
.cabinet[hidden] { display:none; }
.cabinet-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap; }
.cabinet-head h1 { font-size:24px; margin:0 0 4px; }
.cabinet-periods { display:flex; gap:8px; margin:18px 0; flex-wrap:wrap; }
.cabinet-cards { display:flex; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.cabinet-card { min-width:120px; padding:14px 18px; border:1px solid var(--line);
  border-radius:14px; background:var(--panel); display:flex; flex-direction:column; }
.cabinet-card b { font-size:28px; }
.cabinet-card span { color:var(--muted); font-size:12px; }
.cabinet-eng { margin-bottom:14px; font-size:13px; }
.cabinet-list { border:1px solid var(--line); border-radius:14px; overflow:hidden; }
.cabinet-row { padding:12px 16px; border-bottom:1px solid var(--line); display:flex; }
.cabinet-row:last-child { border-bottom:0; }
.cabinet-comment { margin-top:4px; color:var(--muted); font-size:12.5px; }
@media (max-width:760px) { .cabinet { padding:18px 14px 30px; } }
.parts-search { display:flex; gap:8px; max-width:680px; margin:18px 0 10px; }
.parts-search input { flex:1; }
.parts-results { display:flex; flex-direction:column; gap:6px; max-width:900px; margin-bottom:16px; }
.parts-row { display:flex; gap:12px; align-items:baseline; text-align:left; width:100%;
  padding:10px 12px; border:1px solid var(--line); border-radius:10px;
  background:var(--panel); color:var(--text); cursor:pointer; font-size:13px; }
.parts-row:hover { border-color:var(--accent); }
.parts-row b { min-width:150px; color:var(--accent-2); }
.parts-card { max-width:900px; padding:18px; border:1px solid var(--line);
  border-radius:14px; background:var(--panel); }
.parts-card h2 { margin:0 0 4px; font-size:20px; }
.parts-desc { margin-bottom:6px; }
.parts-line { margin-top:12px; font-size:13px; line-height:1.6; }
