:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --font: "SF Pro Text", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 0 1.25rem 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar nav a {
  display: block;
  padding: 0.6rem 1.25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}

.sidebar nav a.nav-item-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.nav-badge {
  min-width: 1.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.sidebar nav a.active .nav-badge {
  background: rgba(59, 130, 246, 0.35);
  color: #dbeafe;
}

.claim-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.claim-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  flex-shrink: 0;
}

.claim-row-unread {
  background: rgba(59, 130, 246, 0.06);
}
.claim-row-unread:hover {
  background: rgba(59, 130, 246, 0.1);
}

.claim-msg-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #1d4ed8;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  vertical-align: middle;
}
.claim-msg-badge-header {
  margin-left: 0;
}

.cell-chat {
  white-space: nowrap;
}

.btn-chat-sm {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 2.25rem;
  padding: 0.35rem 0.55rem !important;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.btn-chat-sm:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.btn-chat-sm-unread {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.12);
}
.btn-chat-sm-icon {
  font-size: 1rem;
  line-height: 1;
}

.chat-list-badge,
.chat-btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: #2563eb;
}

.claim-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.claim-delete-form {
  margin: 0;
  display: inline-flex;
}
.claim-delete-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.btn-danger-outline {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: transparent;
  color: #fca5a5;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
}
.page-subtitle-muted {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.claim-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.btn-chat {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: 1px solid #1d4ed8;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-chat:hover {
  color: #fff;
  filter: brightness(1.06);
  box-shadow: 0 3px 12px rgba(37, 99, 235, 0.35);
}
.btn-chat-unread {
  animation: chat-pulse 2s ease-in-out infinite;
}
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25); }
  50% { box-shadow: 0 2px 16px rgba(37, 99, 235, 0.45); }
}
.btn-chat-label {
  line-height: 1;
}

.inline-chat-link {
  font-weight: 600;
  color: var(--accent);
}
.inline-chat-link:hover {
  text-decoration: underline;
}

.tg-profile-link {
  font-weight: 600;
  color: var(--accent);
}
.tg-profile-link:hover {
  text-decoration: underline;
}

.info-list-spaced dt {
  margin-top: 0.35rem;
}
.info-list-spaced dt:first-child {
  margin-top: 0;
}

.main { flex: 1; padding: 1.5rem 2rem; overflow-x: auto; }

.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2, .card h3 { font-size: 1rem; margin-bottom: 0.75rem; color: var(--text); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }

.chip {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid var(--border);
}

.chip:hover { color: var(--text); text-decoration: none; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--surface2); }

label { display: block; font-size: 0.82rem; color: var(--muted); margin: 0.75rem 0 0.25rem; }
input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.alert-error { background: rgba(239,68,68,.15); border: 1px solid var(--danger); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid var(--success); color: #86efac; }
.alert-warn { background: rgba(245,158,11,.15); border: 1px solid var(--warn); color: #fcd34d; }

.tree { list-style: none; }
.tree li { margin: 0.25rem 0; }
.tree .group { font-weight: 600; padding: 0.4rem 0; }
.tree .sub { padding-left: 1.25rem; color: var(--muted); font-size: 0.88rem; }
.tree a { color: var(--accent); }

.timeline { border-left: 2px solid var(--border); padding-left: 1rem; margin-top: 0.5rem; }
.timeline .item { margin-bottom: 0.75rem; font-size: 0.85rem; }
.timeline .meta { color: var(--muted); font-size: 0.78rem; margin-bottom: 0.25rem; }

.action-history .action-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.action-history .action-item:last-child { border-bottom: none; }
.action-title { font-weight: 500; margin: 0.2rem 0; }
.action-detail {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
}
.action-status .action-title { color: #93c5fd; }
.action-message .action-title { color: #a5b4fc; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  background: var(--surface2);
}

.shipping-box {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 0.5rem;
}

.status-flow { font-size: 0.8rem; color: var(--muted); margin-bottom: 1rem; }

.scenario-card { margin-bottom: 1.5rem; }
.scenario-steps { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.scenario-step {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
}
.scenario-step .step-label { font-weight: 600; margin-bottom: 0.35rem; }
.scenario-step .step-vars { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
.scenario-step textarea { width: 100%; min-height: 5rem; }
.scenario-steps.readonly .scenario-step { border-left-color: var(--border); }
.step-preview {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: pre-wrap;
  background: var(--bg);
  padding: 0.5rem;
  border-radius: 6px;
}

/* --- Навигация --- */
.nav-section { margin-bottom: 1rem; }
.nav-label {
  padding: 0.35rem 1.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.nav-subgroup {
  margin: 0.4rem 0.9rem 0.1rem;
  padding: 0.55rem 0.45rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface2) 55%, transparent);
}

.nav-subgroup-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text);
  padding: 0 0.35rem 0.35rem;
}

.sidebar nav a.nav-subitem {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.1rem 0;
  padding: 0.45rem 0.55rem;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.84rem;
}

.sidebar nav a.nav-subitem:hover,
.sidebar nav a.nav-subitem.active {
  background: var(--surface2);
  color: var(--text);
}

.nav-subitem-icon {
  width: 1.05rem;
  text-align: center;
}

/* --- Страница заявок --- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.page-subtitle { color: var(--muted); font-size: 0.88rem; margin-top: 0.2rem; }
.page-stat { text-align: right; }
.stat-num { font-size: 1.75rem; font-weight: 700; display: block; line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--muted); }

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.filter-group-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table-card { padding: 0; overflow: hidden; }
.table-card table { margin: 0; }
.claims-table th:first-child,
.claims-table td:first-child { padding-left: 1.25rem; }
.claims-table th:last-child,
.claims-table td:last-child { padding-right: 1.25rem; }

.cell-main { font-weight: 500; }
.cell-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.cell-action { text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, monospace; font-size: 0.85em; }

.btn-sm {
  padding: 0.35rem 0.75rem;
  margin-top: 0;
  font-size: 0.8rem;
}

.badge-lg { font-size: 0.85rem; padding: 0.35rem 0.65rem; }
.badge-status { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge-resolution { background: var(--surface2); color: var(--muted); margin-left: 0.35rem; }

.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-inline { color: var(--muted); padding: 0.5rem 0; }
.empty-inline.warn { color: var(--warn); }

/* --- Карточка заявки --- */
.claim-top { margin-bottom: 1rem; }
.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--text); }

.claim-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.claim-header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.claim-header-main .page-title { margin-bottom: 0; font-size: 1.35rem; }
.claim-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tab {
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

.card-accent { border-color: rgba(59, 130, 246, 0.35); }
.card-muted { opacity: 0.95; }

.logistics-quick { margin-bottom: 1rem; }

/* --- Вкладка «Действия» --- */
#panel-actions button.action-choice-btn,
#panel-actions a.action-choice-btn,
#panel-actions .action-manual-toggle {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  font-family: inherit;
}
#panel-actions button.action-choice-btn,
#panel-actions a.action-choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.7rem 1.35rem;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
#panel-actions button.action-choice-btn:hover,
#panel-actions a.action-choice-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.7);
  transform: translateY(-1px);
  color: var(--text);
  text-decoration: none;
}
#panel-actions button.action-choice-btn:active,
#panel-actions a.action-choice-btn:active {
  transform: translateY(0);
}
#panel-actions button.action-choice-btn-alt,
#panel-actions a.action-choice-btn-alt {
  background: rgba(36, 48, 68, 0.9);
  border-color: var(--border);
}
#panel-actions button.action-choice-btn-alt:hover,
#panel-actions a.action-choice-btn-alt:hover {
  background: var(--surface2);
  border-color: rgba(139, 156, 179, 0.45);
}
#panel-actions button.action-choice-btn-danger,
#panel-actions a.action-choice-btn-danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}
#panel-actions button.action-choice-btn-danger:hover,
#panel-actions a.action-choice-btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: #f87171;
  color: #fca5a5;
}
#panel-actions button.action-choice-btn-active,
#panel-actions a.action-choice-btn-active {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.28);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}
#panel-actions button.action-choice-btn-danger.action-choice-btn-active {
  border-color: #f87171;
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.action-flow-card {
  margin-bottom: 1rem;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.07) 0%, var(--surface) 45%);
  border: 1px solid rgba(59, 130, 246, 0.22);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}
.action-flow-card.card-muted {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
}
.action-flow-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}
.action-flow-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.action-flow-badge {
  font-size: 0.78rem;
}
.closed-summary-card .action-flow-head {
  margin-bottom: 0.35rem;
}
.closed-summary-meta {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.closed-summary-list {
  margin: 0;
}
.action-flow-hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.5;
  max-width: 52rem;
}

.action-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.action-btn-grid .action-step-block-inline {
  flex: 1 1 100%;
}
.action-btn-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.action-confirm-area {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(15, 20, 25, 0.45);
  border: 1px solid var(--border);
}
.action-confirm-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.action-confirm-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
  line-height: 1.45;
}
.action-confirm-hint-warn {
  color: var(--warn) !important;
}
.action-confirm-panel {
  margin-top: 0.15rem;
}
.action-confirm-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 540px;
}

.action-steps-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.action-step-block {
  padding: 0.95rem 1rem;
  border-radius: var(--radius);
  background: rgba(15, 20, 25, 0.4);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(59, 130, 246, 0.55);
}
.action-step-block-inline {
  width: 100%;
  margin-top: 0.25rem;
  border-left-color: rgba(59, 130, 246, 0.55);
}
.action-step-block-danger {
  border-left-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.04);
}
.action-ship-waybill-block {
  border-left-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.04);
}
.action-compensation-payout-block {
  border-left-color: rgba(234, 179, 8, 0.65);
  background: rgba(234, 179, 8, 0.06);
}
.action-return-refund-block {
  border-left-color: rgba(96, 165, 250, 0.65);
  background: rgba(96, 165, 250, 0.06);
}
.compensation-payout-amount {
  font-size: 1.15rem;
  color: #fbbf24;
}
.compensation-payout-card + .card,
.compensation-paid-card {
  margin-top: 1rem;
}
.action-ship-data {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.35);
  border: 1px solid var(--border);
}
.action-ship-data-row dt {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.2rem;
  font-weight: 500;
}
.action-ship-data-row dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}
@media (max-width: 700px) {
  .action-ship-data {
    grid-template-columns: 1fr;
  }
}
.action-step-block-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.action-step-icon {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.action-step-block-danger .action-step-icon {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}
.action-step-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.action-step-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
  line-height: 1.4;
}

.action-step-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 540px;
}
.action-step-form .action-choice-btn,
.action-confirm-form .action-choice-btn {
  align-self: flex-start;
  margin-top: 0.15rem;
}

#panel-actions .action-field,
#panel-actions .action-step-form input:not([type=hidden]),
#panel-actions .action-step-form textarea,
#panel-actions .action-step-form select,
#panel-actions .manual-status-form input:not([type=hidden]),
#panel-actions .manual-status-form textarea,
#panel-actions .manual-status-form select {
  width: 100%;
  max-width: 100%;
  padding: 0.6rem 0.85rem;
  margin: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#panel-actions .action-field::placeholder,
#panel-actions .action-step-form textarea::placeholder {
  color: rgba(139, 156, 179, 0.75);
}
#panel-actions .action-field:focus,
#panel-actions .action-step-form input:focus,
#panel-actions .action-step-form textarea:focus,
#panel-actions .action-step-form select:focus,
#panel-actions .manual-status-form input:focus,
#panel-actions .manual-status-form textarea:focus,
#panel-actions .manual-status-form select:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
#panel-actions .action-step-form select option,
#panel-actions .manual-status-form select option {
  background: var(--surface);
  color: var(--text);
}
#panel-actions .action-field.field-invalid,
#panel-actions .action-step-form .field-invalid {
  border-color: #f87171;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}
#panel-actions input.action-field:-webkit-autofill,
#panel-actions .action-step-form input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--surface2) inset;
  -webkit-text-fill-color: var(--text);
}

.action-field-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}

.action-manual-card {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem 1rem;
}
.action-manual-card.action-flow-card {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
}
.action-manual-toggle {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.action-manual-toggle:hover {
  border-color: rgba(139, 156, 179, 0.5);
  background: rgba(36, 48, 68, 0.95);
}
.action-manual-toggle-open {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.action-manual-icon-wrap {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(59, 130, 246, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.action-manual-toggle-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}
.action-manual-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.action-manual-sub {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
}
.action-manual-chevron {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
  transition: transform 0.22s ease, background 0.2s;
}
.action-manual-chevron::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 54%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translate(-50%, -60%) rotate(-45deg);
  transition: border-color 0.2s;
}
.action-manual-toggle:hover .action-manual-chevron {
  background: rgba(59, 130, 246, 0.15);
}
.action-manual-toggle:hover .action-manual-chevron::before {
  border-color: #93c5fd;
}
.action-manual-toggle-open .action-manual-chevron {
  transform: rotate(90deg);
  background: rgba(59, 130, 246, 0.2);
}
.action-manual-toggle-open .action-manual-chevron::before {
  border-color: #93c5fd;
}
.manual-status-panel {
  padding: 1rem 0.75rem 0.25rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: rgba(15, 20, 25, 0.35);
  animation: manual-panel-in 0.22s ease;
}
@keyframes manual-panel-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.manual-status-form {
  max-width: 100%;
}
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.quick-form { display: inline; margin: 0; }

.quick-ship-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  width: 100%;
}
.quick-ship-form input[type=text] {
  flex: 1;
  min-width: 180px;
  margin: 0;
}
.quick-ship-label {
  width: 100%;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.quick-ship-form-stack {
  flex-direction: column;
  align-items: stretch;
}
.quick-ship-textarea {
  width: 100%;
  min-height: 5rem;
  margin: 0;
  resize: vertical;
}
.diagnostics-reject-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.diagnostics-confirm-area {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.diagnostics-confirm-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.diagnostics-confirm-hint {
  margin-bottom: 0.75rem !important;
}
.diagnostics-confirm-hint-warn {
  color: var(--warn) !important;
}
.diagnostics-confirm-panel {
  margin-top: 0.5rem;
}

#diagnostics-quick-actions .btn-decision-active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.18);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}
#diagnostics-quick-actions .btn-danger-outline.btn-decision-active {
  border-color: #dc3545;
  background: rgba(220, 53, 69, 0.12);
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.3);
}

.btn-danger-outline {
  border-color: rgba(220, 53, 69, 0.45);
  color: #f87171;
}
.btn-danger-outline:hover {
  background: rgba(220, 53, 69, 0.1);
}

.field-invalid {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.warehouse-search-card {
  margin-bottom: 1rem;
}
.warehouse-search-form {
  margin: 0;
}
.warehouse-search-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.warehouse-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.warehouse-search-input {
  flex: 1;
  min-width: 220px;
  margin: 0;
}
.warehouse-return-badge {
  display: inline-block;
  margin-top: 0.25rem;
}
.warehouse-supplier-cell {
  min-width: 10rem;
  max-width: 14rem;
}
.warehouse-supplier-plaque {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}
.warehouse-supplier-name {
  font-size: 0.8rem;
}
.warehouse-supplier-purpose {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.warehouse-supplier-date,
.warehouse-supplier-note {
  font-size: 0.75rem;
  line-height: 1.3;
}
.warehouse-supplier-empty {
  font-style: italic;
}
.warehouse-actions {
  text-align: right;
  white-space: nowrap;
}
.warehouse-remove-form {
  margin: 0;
  display: inline;
}
.action-choice-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.warehouse-claim-card .warehouse-claim-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.btn-warehouse-remove {
  margin: 0;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 8px;
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.return-refund-done-note {
  margin: 0 0 1rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.return-refund-done-note a {
  color: var(--accent);
}
.btn-warehouse-remove:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.warehouse-table .warehouse-imei {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.warehouse-search-wrap {
  position: relative;
}
.warehouse-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-height: 280px;
  overflow-y: auto;
}
.warehouse-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.warehouse-suggest-item:hover,
.warehouse-suggest-item:focus {
  background: rgba(59, 130, 246, 0.12);
  outline: none;
}
.warehouse-suggest-imei {
  font-weight: 600;
  font-size: 0.95rem;
}
.warehouse-suggest-meta {
  font-size: 0.78rem;
  color: var(--muted);
}
.warehouse-similar-list {
  list-style: none;
  padding: 0.5rem 0 0;
  margin: 0 0 1rem;
}
.warehouse-similar-list li {
  margin: 0.35rem 0;
}
.warehouse-similar-link {
  font-weight: 600;
  color: var(--accent);
}
.warehouse-similar-link:hover {
  text-decoration: underline;
}

/* --- Вкладка «Клиент» --- */
.client-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, var(--surface) 55%);
  border-color: rgba(59, 130, 246, 0.25);
}
.client-hero-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}
.client-hero-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.client-hero-name {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}
.client-hero-contacts {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.client-hero-sep {
  opacity: 0.5;
}
.client-hero-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.client-stat {
  text-align: center;
  min-width: 4rem;
}
.client-stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
}
.client-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}
.btn-chat-compact {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.client-claims-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.client-claim-card {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.client-claim-card:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
.client-claim-card-current {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}
.client-claim-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.35rem;
}
.client-claim-index {
  font-weight: 700;
  font-size: 0.9rem;
}
.client-claim-current-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
.client-claim-status {
  margin-left: auto;
  font-size: 0.72rem;
}
.client-claim-date {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.client-claim-number {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.client-claim-device {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.35rem;
}
.client-claim-model {
  font-weight: 500;
  font-size: 0.9rem;
}
.client-claim-imei {
  font-size: 0.78rem;
  color: var(--muted);
}
.client-claim-fault {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.client-current-detail {
  margin-bottom: 1rem;
}
.client-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.25rem 1.5rem;
}
.client-detail-grid dt,
.client-detail-grid dd {
  margin: 0;
}
.client-section-hint {
  margin: -0.25rem 0 0.65rem;
}
.reason-block {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(220, 53, 69, 0.06);
  border: 1px solid rgba(220, 53, 69, 0.25);
}
.field-required-label::after {
  content: " *";
  color: #dc3545;
}
.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.scenario-step.current {
  border-left: 3px solid var(--accent);
  padding-left: 0.5rem;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 4px;
}
.scenario-step.current .step-label { font-weight: 600; color: var(--text); }

.admin-only-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.badge-supplier {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}
.badge-muted {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.supplier-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.supplier-item {
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.supplier-item-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.supplier-note {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.action-item.action-supplier .action-title { color: #c084fc; }

.info-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
}
.info-list dt { color: var(--muted); font-size: 0.82rem; }
.info-list dd { margin: 0; }
.info-block { white-space: pre-wrap; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.form-grid .form-full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.scenario-steps.compact .scenario-step {
  padding: 0.35rem 0 0.35rem 0.75rem;
  border-left-width: 2px;
}
.scenario-steps.compact .step-label { font-size: 0.85rem; font-weight: 500; }

.flash.ok { color: var(--success); margin-bottom: 1rem; }

/* --- Чаты (CRM) --- */
.main:has(> .chat-page) {
  padding: 0.75rem 1rem;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.chat-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.chat-layout.chat-layout-room {
  height: 100%;
  min-height: 480px;
  margin-bottom: 0;
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  min-height: 0;
}
.chat-sidebar-head {
  padding: 0.85rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.chat-thread-list { list-style: none; margin: 0; padding: 0; }
.chat-thread-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.chat-thread-item:hover { background: var(--surface2); text-decoration: none; }
.chat-thread-item.active {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent);
  padding-left: calc(1rem - 3px);
}
.chat-avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.chat-avatar-lg { width: 52px; height: 52px; }
.chat-thread-body { flex: 1; min-width: 0; }
.chat-thread-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.chat-thread-name { font-weight: 600; font-size: 0.9rem; }
.chat-thread-time { font-size: 0.72rem; color: var(--muted); }
.chat-thread-sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.chat-thread-preview {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-preview.muted { font-style: italic; }
.chat-unread {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-size: 0.68rem;
  min-width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
}

.chat-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 2rem;
}
.empty-state.compact { padding: 2rem 1rem; }

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #0c1018;
  overflow: hidden;
}
.chat-room-header {
  flex-shrink: 0;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-room-info { flex: 1; min-width: 0; }
.chat-room-title {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.chat-room-meta a { color: var(--accent); }
.chat-msg-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.chat-toast {
  flex-shrink: 0;
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  text-align: center;
}
.chat-toast-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.chat-toast-ok { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.chat-messages-panel { display: none; }
.chat-room-claim { font-size: 0.82rem; margin-top: 0.35rem; }
.chat-client-card {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: 200px;
  max-width: 260px;
}
.chat-client-card-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.info-list.compact { grid-template-columns: 70px 1fr; font-size: 0.82rem; gap: 0.25rem; }

.chat-row {
  display: flex;
  width: 100%;
}
.chat-row-in { justify-content: flex-start; }
.chat-row-out { justify-content: flex-end; }
.chat-row-system { justify-content: center; }

.chat-bubble {
  max-width: min(420px, 78%);
  padding: 0.55rem 0.75rem 0.45rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.chat-bubble.in {
  background: #1a2332;
  border: 1px solid #2a3548;
  border-bottom-left-radius: 4px;
}
.chat-bubble.out {
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-bottom-right-radius: 4px;
}
.chat-bubble.system {
  max-width: 92%;
  background: rgba(245, 158, 11, 0.08);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  font-size: 0.8rem;
  text-align: center;
  padding: 0.5rem 0.85rem;
}
.chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.chat-bubble-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  justify-content: flex-end;
}
.chat-bubble-time {
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.85;
}
.chat-bubble-tag { font-size: 0.7rem; opacity: 0.7; }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
}

.chat-media { margin-bottom: 0.25rem; }
.chat-media-link-wrap { display: block; line-height: 0; }
.chat-media-img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  object-fit: contain;
  background: #000;
}
.chat-media-video {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 10px;
  background: #000;
}
.chat-media-audio {
  display: block;
  width: min(260px, 100%);
  height: 36px;
}
.chat-media-file {
  color: var(--accent);
  font-size: 0.88rem;
  text-decoration: none;
}
.chat-media-file:hover { text-decoration: underline; }
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

.chat-compose {
  flex-shrink: 0;
  padding: 0.65rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-compose-bar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.chat-compose textarea {
  flex: 1;
  margin: 0;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 0.55rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.9rem;
  line-height: 1.4;
  font-family: inherit;
}
.chat-compose textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-attach-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chat-attach-btn:hover {
  color: var(--accent);
  background: var(--surface2);
}
.btn-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}
.chat-compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.chat-attach-name {
  font-size: 0.72rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}
.chat-compose-hint {
  font-size: 0.68rem;
  color: var(--muted);
  margin-left: auto;
}

@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout-room .chat-sidebar { display: none; }
  .chat-bubble { max-width: 88%; }
  .chat-compose-hint { display: none; }
  .chat-client-card { margin-left: 0; width: 100%; max-width: none; }
}

/* --- Дерево контента --- */
.content-page { max-width: 1200px; }
.content-header {
  margin-bottom: 0.75rem;
}
.content-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 0.35rem;
}
.btn-toolbar { min-width: 36px; }
.content-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) { .content-layout { grid-template-columns: 1fr; } }
.content-tree-card { min-height: 400px; }
.content-editor-card { min-height: 200px; }
.form-stack label { display: block; margin-top: 0.65rem; }
.form-stack label:first-child { margin-top: 0; }
.fault-tree { display: flex; flex-direction: column; gap: 0.35rem; }
.fault-tree-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem 0.65rem;
  background: var(--bg);
  margin-bottom: 0.65rem;
}
.fault-tree-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.fault-tree-row:hover { background: var(--surface2); }
.fault-tree-row.selected {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface2));
  outline: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.fault-tree-row.depth-1 { padding-left: 1.25rem; }
.fault-tree-row.depth-2 { padding-left: 2.25rem; }
.fault-tree-row.depth-3 { padding-left: 3.25rem; }
.fault-tree-row.depth-4 { padding-left: 4.25rem; }
.fault-tree-icon { flex-shrink: 0; width: 1.25rem; text-align: center; }
.fault-tree-title {
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 120px;
}
.fault-tree-rename-input {
  flex: 1;
  min-width: 120px;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* --- Login --- */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 1.75rem;
}
.login-title {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}
.login-subtitle {
  color: var(--muted);
  margin-bottom: 1.25rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.login-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
}
.login-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.login-submit {
  margin-top: 1rem;
  width: 100%;
}
.sidebar-logout-form {
  margin-top: auto;
  padding: 0.75rem 1rem 1rem;
}
.nav-logout-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 0.55rem 0.75rem;
}
.nav-logout-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

