/* ============================================================
   Mobile Desk — мобильная диспетчерская
   Цветовая кодировка: красный (Новое/Срочно), жёлтый (В работе),
   зелёный (Готово), серый (Ожидает/Закрыта).
   ============================================================ */

:root {
  --mp-blue: #0b4f8a;
  --mp-blue-2: #1a7ab2;
  --mp-accent: #41b1ff;
  --mp-blue-soft: #e8f2fb;
  --ink: #16202e;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #eef1f6;
  --white: #fff;

  --st-red: #e5484d;
  --st-red-soft: #fdecec;
  --st-yellow: #f4b740;
  --st-yellow-soft: #fdf3dd;
  --st-green: #23a35e;
  --st-green-soft: #e6f6ee;
  --st-grey: #98a2b3;
  --st-grey-soft: #f0f2f5;

  --r: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============ Шапка ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(90deg, var(--mp-blue), var(--mp-blue-2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(11,79,138,.25);
}
.topbar-title { flex: 1; min-width: 0; }
.title-main { font-size: 17px; font-weight: 700; line-height: 1.2; }
.title-sub { font-size: 12px; opacity: .85; margin-top: 1px; }
.icon-btn {
  width: 40px; height: 40px;
  border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
  flex: 0 0 auto;
}
.icon-btn:active { background: rgba(255,255,255,.24); }
.burger { width: 18px; height: 14px; position: relative; display: inline-block; }
.burger::before, .burger::after, .burger span {
  content: ""; position: absolute; left: 0; width: 18px; height: 2px;
  background: #fff; border-radius: 2px;
}
.burger span { top: 6px; }
.burger::before { top: 0; }
.burger::after { top: 12px; }
.back { font-size: 26px; font-weight: 400; }
.topbar-user {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; text-transform: uppercase;
  flex: 0 0 auto;
}

/* ============ Табы ============ */
.tabs {
  position: sticky;
  top: calc(60px + var(--safe-top));
  z-index: 35;
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
  transition: .15s;
}
.tab .badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--mp-blue-soft); color: var(--mp-blue);
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab.active {
  background: var(--mp-blue); color: #fff; border-color: var(--mp-blue);
}
.tab.active .badge { background: rgba(255,255,255,.22); color: #fff; }

/* ============ Лента ============ */
.feed { padding: 4px 14px calc(110px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(16,32,64,.05);
  overflow: hidden;
  transition: transform .12s, box-shadow .12s;
}
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.prio-cube { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.card-id { font-size: 12px; font-weight: 700; color: var(--muted); }
.card-time { margin-left: auto; font-size: 11.5px; color: var(--muted); }

.card-title {
  margin: 0 0 8px;
  font-size: 15px; font-weight: 700; line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.meta-row {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 12.5px; color: var(--muted); line-height: 1.4;
}
.meta-icon { color: var(--mp-blue-2); font-weight: 700; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ Кнопки ============ */
.btn {
  border: 0; border-radius: 11px; cursor: pointer;
  font-size: 14px; font-weight: 700;
  padding: 12px 16px;
  min-height: 46px;
  transition: .12s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:active { filter: brightness(.92); transform: scale(.98); }
.btn-lg { flex: 1; min-height: 52px; font-size: 15px; }

.btn-take { background: var(--mp-blue); color: #fff; }
.btn-status { background: var(--mp-blue-soft); color: var(--mp-blue); }
.btn-comment { background: var(--white); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--st-red); color: #fff; }
.btn-plain { background: var(--white); color: var(--ink); border: 1px solid var(--line); }

/* ============ Пусто ============ */
.empty {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 70px 20px;
}
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--white); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--st-green);
}

/* ============ Боковое меню ============ */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(14,23,38,.5);
  opacity: 0; visibility: hidden; transition: .2s;
}
.scrim.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 51;
  width: min(82vw, 320px);
  background: var(--white);
  transform: translateX(-100%);
  transition: transform .22s ease;
  display: flex; flex-direction: column;
  box-shadow: 4px 0 30px rgba(0,0,0,.18);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(22px + var(--safe-top)) 18px 16px;
  background: linear-gradient(90deg, var(--mp-blue), var(--mp-blue-2));
  color: #fff;
}
.drawer-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; text-transform: uppercase;
}
.drawer-name { font-size: 15px; font-weight: 700; }
.drawer-sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.drawer-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px;
  font-size: 15px; font-weight: 600; color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid #f4f6f9;
}
.drawer-item:active { background: var(--mp-blue-soft); }
.drawer-foot { border-top: 1px solid var(--line); padding: 8px 0 calc(14px + var(--safe-bottom)); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.red { background: var(--st-red); }
.dot.yellow { background: var(--st-yellow); }
.dot.green { background: var(--st-green); }
.dot.grey { background: var(--st-grey); }
.dot.blue { background: var(--mp-blue-2); }

/* ============ Нижний шит (смена статуса / комментарий) ============ */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(14,23,38,.45);
  opacity: 0; visibility: hidden; transition: .2s;
}
.sheet-scrim.open { opacity: 1; visibility: visible; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  transform: translateY(100%);
  transition: transform .24s ease;
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-height: 78vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,.2);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 0 auto 12px;
}
.sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 14.5px; font-weight: 600;
  cursor: pointer; background: var(--white);
}
.status-opt:active { background: var(--mp-blue-soft); }
.status-opt .dot { width: 14px; height: 14px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 12px; font-size: 15px; color: var(--ink);
  outline: none; background: var(--white);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--mp-blue-2);
  box-shadow: 0 0 0 3px rgba(26,122,178,.15);
}
.sheet-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ============ Детальная карточка ============ */
.detail-body { padding: 14px calc(14px) calc(140px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.detail-status {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 700;
  border-radius: 999px; padding: 7px 14px;
}
.st-red .status-pill { background: var(--st-red-soft); color: var(--st-red); }
.st-yellow .status-pill { background: var(--st-yellow-soft); color: #8a5a00; }
.st-green .status-pill { background: var(--st-green-soft); color: var(--st-green); }
.st-grey .status-pill { background: var(--st-grey-soft); color: var(--muted); }
.prio-pill {
  border: 1.5px solid; border-radius: 999px;
  padding: 6px 12px; font-size: 12.5px; font-weight: 700;
}
.detail-title { margin: 0 0 14px; font-size: 19px; line-height: 1.35; font-weight: 750; }

.block {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.block-head {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 800; color: var(--muted);
  margin-bottom: 10px;
}
.kv { display: flex; flex-direction: column; gap: 7px; }
.kv-row { display: flex; gap: 10px; font-size: 13.5px; }
.kv-row .k { flex: 0 0 34%; color: var(--muted); font-weight: 600; }
.kv-row .v { flex: 1; color: var(--ink); font-weight: 500; }

.content { font-size: 14px; line-height: 1.55; color: var(--ink); word-break: break-word; }
.content p { margin: 0 0 8px; }
.content:last-child p:last-child { margin-bottom: 0; }
.content img { max-width: 100%; height: auto; border-radius: 8px; }
.empty-inline { color: var(--muted); font-style: italic; }

/* Таймлайн */
.timeline {
  position: relative;
  padding-left: 18px;
  background-color: #d9e6cd;
  background-image: url('../chat-background-pattern.svg');
  background-repeat: repeat;
  background-size: 900px 1600px;
  border-radius: 8px;
}
.tl-ev { position: relative; margin-bottom: 14px; }
.tl-ev:last-child { margin-bottom: 0; }
.tl-dot {
  position: absolute; left: -18px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--mp-blue-2);
}
.tl-dot[data-kind="create"] { background: var(--st-green); }
.tl-dot[data-kind="solution"] { background: var(--st-yellow); }
.tl-ev.private .tl-dot { background: var(--st-grey); }
.tl-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.tl-author { font-size: 13px; font-weight: 700; }
.tl-priv {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  background: var(--st-grey-soft); border-radius: 4px; padding: 1px 6px;
}
.tl-time { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.tl-content { font-size: 13.5px; line-height: 1.5; color: #344054; }

/* Messenger dialog (№75): client (requester) left, staff + system right.
   Bubbles: client white with black border and black text; staff replies
   light-green; comments (private) and system messages light-gray; black text. */
.tl-body { max-width: 86%; }
.side-client .tl-body { margin-right: auto; }
.side-staff .tl-body, .side-system .tl-body { margin-left: auto; }
.bubble {
  position: relative;
  border-radius: 14px;
  padding: 10px 13px;
  background: var(--white);
  border: 1px solid var(--line);
  word-break: break-word;
}
.side-client .bubble { border-top-right-radius: 4px; border-top-left-radius: 0; }
.side-staff .bubble { border-top-left-radius: 4px; border-top-right-radius: 0; }
/* quote-like tail: client (left) top-left, staff/system/private (right) mirrored top-right */
.side-client .bubble::before,
.side-client .bubble::after,
.side-staff .bubble::before,
.side-staff .bubble::after,
.tl-ev.private .bubble::before,
.tl-ev.private .bubble::after,
.side-system .bubble::before,
.side-system .bubble::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  top: 0;
  border-style: solid;
}
.side-client .bubble::before { left: -7px; border-width: 7px 7px 0 0; border-color: #000 transparent transparent transparent; }
.side-client .bubble::after { left: -5px; border-width: 5px 5px 0 0; border-color: #fff transparent transparent transparent; }
.side-staff .bubble::before,
.side-system .bubble::before { right: -7px; border-width: 7px 0 0 7px; border-color: transparent transparent transparent #000; }
.side-staff .bubble::after,
.side-system .bubble::after { right: -5px; border-width: 5px 0 0 5px; border-color: transparent transparent transparent rgb(174,238,181); }
.tl-ev.private .bubble::before { right: -7px; border-width: 7px 0 0 7px; border-color: transparent transparent transparent #000; }
.tl-ev.private .bubble::after { right: -5px; border-width: 5px 0 0 5px; border-color: transparent transparent transparent #eceff3; }
/* client (left): white, black border, black text */
.side-client .bubble { background: #fff; border: 1px solid #000; }
.side-client .tl-author,
.side-client .bubble .tl-content { color: #000; }
.side-client .tl-time { color: #667085; }
/* public replies (specialist + system): green, black frame, black text */
.side-staff .bubble,
.side-system .bubble { background: rgb(174,238,181); border: 1px solid #000; }
.side-staff .tl-author,
.side-staff .bubble .tl-content,
.side-system .tl-author,
.side-system .bubble .tl-content { color: #000; }
.side-staff .tl-time,
.side-system .tl-time { color: #667085; }
/* comments (private): gray, black frame, black text */
.tl-ev.private .bubble { background: #eceff3; border: 1px solid #000; }
.tl-ev.private .tl-author,
.tl-ev.private .bubble .tl-content { color: #000; }
.tl-ev.private .tl-time { color: #667085; }

/* ============ Нижняя панель действий ============ */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; gap: 8px;
  padding: 10px 14px calc(10px + var(--safe-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
}
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); z-index: 70;
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0; visibility: hidden; transition: .2s;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; visibility: visible; }
.toast.err { background: var(--st-red); }

/* Свайпы */
.swiping { transition: none !important; }

@media (min-width: 768px) {
  body { background: #dfe4ec; }
  .feed, .detail-body, .tabs, .actionbar, .topbar { max-width: 640px; margin-left: auto; margin-right: auto; }
}
/* ============================================================
   /hd: вход, уведомления, роли, дополнительные состояния.
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-bottom));
  background: radial-gradient(1200px 600px at 50% -10%, #1b6aa5 0%, #0b4f8a 42%, #07365f 100%);
}
.login-wrap { width: 100%; max-width: 430px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin: 0 4px 18px; color: #fff; }
.login-brand img { height: 44px; width: auto; display: block; }
.login-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.login-brand-text b { font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.login-brand-text span { font-size: 12.5px; opacity: .82; }
.login-card { background: #fff; border-radius: 18px; padding: 24px 20px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.login-card h1 { margin: 0 0 6px; font-size: 21px; color: var(--ink); }
.login-sub { margin: 0 0 18px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.login-field { display: block; margin-bottom: 14px; }
.login-field span { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.login-field input {
  width: 100%; box-sizing: border-box; border: 1.5px solid #d5dbe5; border-radius: 11px;
  padding: 13px 14px; font-size: 16px; color: var(--ink); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,79,138,.12); }
.login-submit { width: 100%; margin-top: 4px; }
.login-error { background: #fff1f1; border: 1px solid #f3c2c2; color: #a5161b; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.4; margin-bottom: 14px; }
.login-help { text-align: center; margin-top: 14px; font-size: 13px; }
.login-help a { color: var(--brand); text-decoration: none; }
.login-foot { text-align: center; color: rgba(255,255,255,.78); font-size: 12px; margin-top: 14px; line-height: 1.4; }

.notice { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4; background: #eef5fb; color: #0b4f8a; border: 1px solid #cfe2f2; }
.notice.error { background: #fff1f1; color: #a5161b; border-color: #f3c2c2; }
.notice.success { background: #edf9f1; color: #176c3a; border-color: #c7ecd3; }

.drawer-roles { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 12px; }
.role-chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: #eef5fb; color: #0b4f8a; }
/* ============================================================
   /hd: кликабельная тема, VIP/максимальный приоритет, участники,
   меню «Действия с заявкой», мобильная адаптация.
   ============================================================ */
.card-title-link {
  cursor: pointer;
  color: var(--brand);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.card-title-link:hover,
.card-title-link:focus-visible {
  color: #07365f;
  text-decoration-thickness: 2px;
}
.card-title-link::after {
  content: " ›";
  font-weight: 800;
  color: var(--brand);
}

.card.priority-high {
  background: #fff1f1;
  border-color: #f3c2c2;
  box-shadow: 0 2px 10px rgba(229, 72, 77, .08);
}
.vip-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
  line-height: 1.6;
}
.detail-status.priority-high {
  background: #fff1f1;
  border-color: #f3c2c2;
}

.participant-card {
  padding: 10px 0;
  border-bottom: 1px solid #edf0f4;
}
.participant-card:last-child { border-bottom: 0; padding-bottom: 0; }
.participant-card:first-child { padding-top: 0; }
.participant-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.participant-name { font-size: 14.5px; font-weight: 750; color: var(--ink); }
.participant-login { font-size: 12px; color: var(--muted); margin-top: 2px; }
.contact-list { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.contact-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.contact-item:hover { color: var(--brand); text-decoration: underline; }
.contact-icon { color: var(--brand); font-size: 13px; width: 16px; text-align: center; }

/* Меню действий в нижнем шите */
.action-menu { display: flex; flex-direction: column; gap: 8px; }
.action-menu .action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e3e8ef;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.action-menu .action-item:hover,
.action-menu .action-item:focus-visible {
  border-color: var(--brand);
  background: #f5f9fd;
}
.action-menu .action-item .ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #eef5fb;
  color: var(--brand);
  font-size: 15px;
  flex: 0 0 auto;
}
.action-form .field { margin-bottom: 10px; }
.action-form textarea,
.action-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #d5dbe5;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
}
.action-form textarea { min-height: 110px; resize: vertical; }
.action-form input[type="file"] { width: 100%; font-size: 13px; }
.form-hint { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.assignee-results { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; max-height: 230px; overflow: auto; }
.assignee-result {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border: 1px solid #e3e8ef; border-radius: 9px; background: #fff;
  font-size: 13.5px; cursor: pointer; text-align: left;
}
.assignee-result:hover { border-color: var(--brand); background: #f5f9fd; }
.assignee-result.active { border-color: var(--brand); background: #eef5fb; }
.assignee-result small { display: block; color: var(--muted); font-size: 11.5px; }

/* Мобильная адаптация */
.tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab { flex: 0 0 auto; white-space: nowrap; }
.actionbar { flex-wrap: wrap; gap: 8px; }
.actionbar .btn { flex: 1 1 100%; }
.card-actions .btn { width: 100%; }

@media (max-width: 520px) {
  .topbar-title .title-main { font-size: 16px; }
  .topbar-title .title-sub { font-size: 11.5px; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .tabs .tab { padding: 8px 10px; font-size: 12.5px; }
  .feed { padding-left: 10px; padding-right: 10px; }
  .card { padding: 12px 12px 10px; }
  .detail-body { padding-left: 10px; padding-right: 10px; }
  .detail-title { font-size: 19px; }
  .detail-status { flex-wrap: wrap; }
  .sheet { max-height: 88vh; }
  .sheet-body { max-height: 70vh; overflow: auto; }
  .action-menu .action-item { padding: 11px 12px; font-size: 14px; }
}
/* Кнопка закрытия нижнего шита (действия можно свернуть без выбора действия) */
.sheet { position: fixed; }
.sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 5;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #eef1f5;
  color: #475467;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover { background: #e3e8ef; color: var(--ink); }
.sheet-title { padding-right: 44px; }
/* Выбор каталога STAFF / STUD на странице входа */
.login-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #d5dbe5;
  border-radius: 11px;
  padding: 13px 14px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.login-field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,79,138,.12); }
/* Личный кабинет клиента */
.client-solved { background: #f1fbf5; border-color: #c7ecd3; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 10px 0 14px; }
.star {
  border: 0;
  background: transparent;
  padding: 2px 4px;
  font-size: 34px;
  line-height: 1;
  color: #d5dbe5;
  cursor: pointer;
  transition: color .12s, transform .12s;
}
.star:hover { transform: scale(1.08); }
.star.active { color: #f4b740; }
/* ============================================================
   ПК / планшеты: полноэкранная версия.
   Мобильная вёрстка (до 900px) остаётся без изменений.
   ============================================================ */
@media (min-width: 900px) {
  body { background: #eef1f5; }

  .topbar,
  .tabs,
  .feed,
  .detail-body,
  .actionbar {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .topbar {
    padding-left: 28px;
    padding-right: 28px;
  }
  .topbar-title .title-main { font-size: 21px; }
  .topbar-title .title-sub  { font-size: 13px; }

  .tabs {
    padding: 12px 28px;
    gap: 8px;
    justify-content: flex-start;
  }
  .tabs .tab {
    padding: 9px 17px;
    font-size: 14px;
  }

  .feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    align-items: start;
    padding: 20px 28px 110px;
  }
  .feed .notice,
  .feed .empty {
    grid-column: 1 / -1;
  }
  .feed .card {
    margin: 0;
    padding: 16px 18px 14px;
  }
  .card-title { font-size: 17px; }

  .detail-body {
    max-width: none;
    margin: 0;
    padding: 24px 32px 120px;
  }
  .detail-title { font-size: 26px; }

  .actionbar {
    justify-content: flex-end;
    padding: 12px 28px 14px;
  }
  .actionbar .btn {
    flex: 0 0 auto;
    min-width: 210px;
    width: auto;
  }

  .drawer { width: 360px; }
  .sheet {
    left: 50%;
    right: auto;
    width: min(680px, calc(100% - 48px));
    transform: translate(-50%, 100%);
    border-radius: 18px 18px 0 0;
  }
  .sheet.open { transform: translate(-50%, 0); }
}
/* Текущий режим работы (Исполнитель / Клиент) */
.topbar-mode {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.drawer-mode {
  padding: 0 18px 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.drawer-mode b { color: var(--brand); }
.drawer-foot .drawer-mode-lower {
  margin-top: 8px;
  padding: 10px 18px 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 520px) {
  .topbar-mode { font-size: 9.5px; padding: 3px 7px; }
}

/* ============================================================
   Клиентский кабинет: зеркальная переписка.
   Сообщения клиента — справа, остальные — слева.
   ============================================================ */
body.client-view .side-client .tl-body {
  margin-left: auto;
  margin-right: 0;
}
body.client-view .side-staff .tl-body,
body.client-view .side-system .tl-body {
  margin-left: 0;
  margin-right: auto;
}

body.client-view .side-client .bubble {
  border-top-left-radius: 4px;
  border-top-right-radius: 0;
}
body.client-view .side-staff .bubble,
body.client-view .side-system .bubble {
  border-top-right-radius: 4px;
  border-top-left-radius: 0;
}

/* Клиент справа: хвостик справа, белый фон */
body.client-view .side-client .bubble::before {
  left: auto;
  right: -7px;
  border-width: 7px 0 0 7px;
  border-color: transparent transparent transparent #000;
}
body.client-view .side-client .bubble::after {
  left: auto;
  right: -5px;
  border-width: 5px 0 0 5px;
  border-color: transparent transparent transparent #fff;
}

/* Остальные слева: хвостик слева, зелёный фон */
body.client-view .side-staff .bubble::before,
body.client-view .side-system .bubble::before {
  right: auto;
  left: -7px;
  border-width: 7px 7px 0 0;
  border-color: #000 transparent transparent transparent;
}
body.client-view .side-staff .bubble::after,
body.client-view .side-system .bubble::after {
  right: auto;
  left: -5px;
  border-width: 5px 5px 0 0;
  border-color: rgb(174,238,181) transparent transparent transparent;
}
/* Подчиненные подразделения */
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--brand); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.dept-hint { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin: 0 0 12px; }
.dept-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dept-back { font-size: 12.5px; font-weight: 600; color: var(--brand); text-decoration: none; }
.dept-back:hover { text-decoration: underline; }
.dept-path { font-size: 12.5px; color: var(--muted); margin: -2px 0 14px; line-height: 1.4; }
.dept-subhead { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 0 8px; }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.dept-group { display: block; text-decoration: none; color: var(--ink); margin: 0; }
.dept-group:hover { border-color: var(--brand); box-shadow: 0 4px 14px rgba(16,32,64,.1); }
.dept-group-title { font-size: 14px; font-weight: 750; line-height: 1.3; }
.dept-group-meta { font-size: 12px; color: var(--muted); margin-top: 5px; }
.dept-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.dept-member { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-decoration: none; color: var(--ink); }
.dept-member:hover { border-color: var(--brand); background: #f5f9fd; }
.dept-member.active { border-color: var(--brand); background: #eef5fb; }
.dept-member-name { font-size: 13.5px; font-weight: 650; }
.dept-member-login { font-size: 11.5px; color: var(--muted); }
.dept-filter { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.dept-filter b { color: var(--ink); }
.dept-filter a { color: var(--brand); margin-left: 6px; }
.dept-tickets { display: grid; gap: 10px; }
.dept-ticket { display: block; text-decoration: none; color: var(--ink); margin: 0; }
.dept-ticket:hover { border-color: var(--brand); }
.dept-ticket-title { font-size: 14.5px; font-weight: 750; line-height: 1.3; margin: 6px 0 8px; }
.dept-ticket-status { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.dept-ticket .card-meta { margin-top: 6px; }

@media (min-width: 900px) {
  .dept-tickets { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
}

/* ============================================================
   Подразделения: дерево групп и таблица исполнителей
   ============================================================ */
.dept-tree-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
  overflow-x: auto;
}
.dept-tree { list-style: none; margin: 0; padding: 0; }
.dept-tree .dept-tree {
  margin-left: 18px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
.dept-tree-item { margin: 0; }
.dept-tree-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 7px 6px;
  text-decoration: none;
  color: var(--ink);
  border-radius: 6px;
}
.dept-tree-row:hover { background: #f3f8fd; }
.dept-tree-name { font-size: 13.5px; font-weight: 650; }
.dept-tree-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.dept-stat b, .dept-stat-total b { color: var(--ink); }

.dept-summary {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #f7fafd;
  margin-bottom: 8px;
}
.dept-summary-total { display: flex; flex-direction: column; }
.dept-summary-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.dept-summary-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--brand);
}
.dept-summary-items {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}
.dept-summary-items b { color: var(--ink); }
.dept-note { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 6px 0 0; }

.dept-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.departments-page .dept-table-wrap { max-height: 72vh; overflow: auto; }
.dept-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dept-table th, .dept-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.dept-table thead th {
  background: #f5f8fc;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.dept-table .num {
  text-align: right;
  width: 76px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.dept-table .total { font-weight: 800; }
.dept-table tbody tr:last-child td { border-bottom: 0; }
.dept-table tbody tr:hover { background: #f8fbfe; }
.dept-table th[data-sort] { cursor: pointer; user-select: none; }
.dept-table th[data-sort]::after {
  content: '↕';
  margin-left: 5px;
  font-weight: 400;
  opacity: .35;
}
.dept-table th.sort-asc::after { content: '↑'; opacity: 1; }
.dept-table th.sort-desc::after { content: '↓'; opacity: 1; }
.dept-table thead th { position: sticky; top: 0; z-index: 1; }
.dept-name-cell { min-width: 260px; }
.dept-table-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.dept-table-link:hover { color: var(--brand); text-decoration: underline; }
.dept-click-row { cursor: pointer; }
.dept-ticket-table .dept-ticket-name { min-width: 300px; font-weight: 600; }
.dept-ticket-table td:nth-child(3),
.dept-ticket-table td:nth-child(5) { white-space: nowrap; }
.dept-ticket-table .status-pill { padding: 3px 9px; font-size: 11.5px; }
.dept-exec-name { display: block; font-weight: 650; }
.dept-exec-login { display: block; font-size: 11px; color: var(--muted); }
.dept-row-muted td { background: #fbfbfc; }
.dept-row-muted .dept-exec-name { color: var(--muted); font-weight: 600; }

@media (max-width: 700px) {
  .dept-tree-row { flex-direction: column; gap: 3px; }
  .dept-tree-stats { white-space: normal; gap: 8px; }
  .dept-summary { gap: 12px; }
  .dept-summary-value { font-size: 24px; }
  .dept-table th, .dept-table td { padding: 8px 9px; }
  .dept-table .num { width: 58px; }
}