:root {
  --col-chats: 260px;
  --col-templates: 272px;
  --col-resizer: 6px;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent-wb: #a73afd;
  --accent-ozon: #005bff;
  --accent-telegram: #2aabee;
  --accent-max: #6b52f0;
  --accent-max-gradient: linear-gradient(90deg, #48d6ff 0%, #4a57f2 48%, #b44ae8 100%);
  --accent-active: #2563eb;
  --unread-accent: #2563eb;
  --unread-accent-dark: #1d4ed8;
  --unread-bg: #eff6ff;
  --order-bg: #e8eaed;
  --client-bubble: #ffffff;
  --seller-bubble: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns:
    var(--col-chats)
    var(--col-resizer)
    minmax(280px, 1fr)
    var(--col-resizer)
    var(--col-templates);
  grid-template-rows: 1fr;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
}

.rocket-desktop {
  --col-chats: 240px;
  --col-templates: 272px;
}

.col-resizer {
  position: relative;
  z-index: 6;
  cursor: col-resize;
  touch-action: none;
  background: transparent;
  transition: background 0.15s ease;
}

.col-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: var(--border);
  pointer-events: none;
}

.col-resizer:hover,
.col-resizer.col-resizer--active {
  background: rgba(37, 99, 235, 0.12);
}

.col-resizer:hover::after,
.col-resizer.col-resizer--active::after {
  background: var(--accent-active, #2563eb);
  width: 2px;
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.col-resizing * {
  cursor: col-resize !important;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.panel-chats {
  min-width: 0;
}

.panel-active {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.panel-templates {
  border-right: none;
  border-left: none;
  min-height: 0;
  min-width: 0;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h1,
.panel-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.panel-header-chats {
  gap: 8px;
}

.chat-toolbar-row {
  display: flex;
  gap: 8px;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-toolbar-row .chat-filter-wrap {
  flex: 1;
  min-width: 0;
  padding: 0;
  border-bottom: none;
}

.chat-filter-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  cursor: pointer;
  text-align: left;
}

.chat-filter-toggle:hover {
  background: #f8f9fb;
  border-color: #c5d0e0;
}

.chat-filter-toggle[aria-expanded="true"] {
  border-color: var(--accent-active);
  background: #eef4ff;
}

.chat-filter-toggle::after {
  content: "▾";
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.chat-filter-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 4px);
  z-index: 40;
  padding-top: 4px;
}

.chat-filter-panel-inner {
  max-height: min(320px, 45vh);
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.chat-filter-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 2px;
  font-size: 12px;
  color: var(--text, #1a1a1a);
  cursor: pointer;
  user-select: none;
}

.chat-filter-option:hover {
  color: var(--accent-active);
}

.chat-filter-option input {
  width: 14px;
  height: 14px;
  margin: 2px 0 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent-active);
}

.chat-filter-option input[type="radio"] {
  border-radius: 50%;
}

.chat-filter-option span {
  line-height: 1.35;
}

.chat-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-search-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

.chat-search-input:focus {
  outline: none;
  border-color: var(--accent-active, #2563eb);
}

.chat-search-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--accent-active, #2563eb);
  border-radius: 8px;
  background: var(--accent-active, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chat-search-btn:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-refresh-chats {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--accent-active);
}

.btn-refresh-chats:hover {
  background: #e8f0fe;
}

.btn-refresh-chats:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn-refresh-chats.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.badge {
  font-size: 11px;
  color: var(--muted);
  max-width: 120px;
  text-align: right;
}

.chat-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-item:hover {
  background: #f8f9fb;
}

.chat-item.active {
  background: #dbeafe;
  border-left: 4px solid #1d4ed8;
  box-shadow: inset 0 0 0 1px #93c5fd;
}

.chat-item.active .chat-item-title {
  color: #1e3a8a;
}

.chat-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-item-title {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-saved-icon,
.chat-item-pin-icon {
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1;
}

.chat-item-saved .chat-item-title {
  color: #2563eb;
}

.chat-item-pinned {
  background: #f3f4f6;
}

.chat-item-pinned:hover:not(.active) {
  background: #eceef2;
}

.chat-item-pinned.unread:not(.active),
.chat-item-pinned.is-new:not(.active) {
  background: #eef1f5;
}

.chat-item-pinned-last {
  border-bottom: 2px solid #cbd5e1;
  margin-bottom: 8px;
  box-shadow: 0 8px 0 0 #fff;
}

.chat-item-pinned.active {
  background: #dbeafe;
}

.chat-unread-badge {
  flex-shrink: 0;
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--unread-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}

.chat-item.active .chat-unread-badge,
.chat-item.active .chat-unread-badge-new {
  background: var(--unread-accent);
  color: #fff;
}

.chat-unread-badge-new {
  font-weight: 600;
  font-size: 10px;
  text-transform: lowercase;
}

.chat-item-preview {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.chat-item-time {
  flex-shrink: 0;
}

.chat-item-code {
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.chat-item.unread:not(.active),
.chat-item.is-new:not(.active) {
  background: var(--unread-bg);
  border-left: 3px solid var(--unread-accent);
}

.chat-item.unread:not(.active) .chat-item-title,
.chat-item.is-new:not(.active) .chat-item-title {
  color: var(--unread-accent-dark);
  font-weight: 700;
}

.chat-item.unread:not(.active) .chat-item-preview {
  color: var(--unread-accent);
}

.market-switch {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.market-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
}

.market-btn-icon {
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
}

.market-btn-icon svg {
  display: block;
}

.market-btn[data-market="wb"] {
  background: var(--accent-wb);
}

.market-btn[data-market="ozon"] {
  background: var(--accent-ozon);
}

.market-btn[data-market="telegram"] {
  background: var(--accent-telegram);
}

.market-btn[data-market="max"] {
  background: var(--accent-max-gradient);
}

.market-btn:not(.active) {
  opacity: 0.42;
}

.market-btn.active {
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.market-btn:hover {
  opacity: 0.85;
}

.market-btn.active:hover {
  opacity: 1;
}

.order-bar {
  background: var(--order-bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 96px;
  max-height: 160px;
  overflow-y: auto;
  flex-shrink: 0;
}

.order-bar-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
}

.order-placeholder {
  color: var(--muted);
  font-size: 14px;
}

.order-image-wrap {
  flex-shrink: 0;
  width: 63px;
  height: 84px;
  border-radius: 10px;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.order-image.is-broken {
  display: none;
}

.order-image-placeholder {
  font-size: 28px;
  color: #9ca3af;
}

.order-info {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}

.order-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.order-client-name {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-assignment-inline,
.order-qr-inline {
  flex-shrink: 0;
  font-size: 13px;
  white-space: nowrap;
}

.order-client-name-block {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.order-status-empty {
  color: var(--muted);
  font-weight: 500;
}

.order-assignment-inline .order-field-value {
  font-weight: 700;
}

.order-fulfillment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-bottom: 6px;
  line-height: 1.25;
}

.order-qr-line {
  min-width: 0;
}

.order-status-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.order-fields {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-field {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.order-field-label {
  color: var(--muted);
}

.order-field-assignment .order-field-value {
  font-weight: 700;
  color: var(--text);
}

.order-supply-qr {
  font-weight: 700;
  color: var(--text);
}

.order-status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  background: #16a34a;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.fulfill-wb-btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--accent-wb, #a73afd);
  border-radius: 8px;
  background: var(--accent-wb, #a73afd);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.fulfill-wb-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.fulfill-wb-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.match-wb-btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 14px;
  border: 1px solid #7c3aed;
  border-radius: 8px;
  background: #fff;
  color: #6d28d9;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.match-wb-btn:hover:not(:disabled) {
  background: #f5f3ff;
}

.match-wb-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.match-ozon-btn {
  background: #005bff;
  color: #fff;
}

.match-ozon-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.match-ozon-btn:disabled {
  opacity: 0.45;
}

.match-wb-dialog {
  width: min(560px, 92vw);
  max-height: 88vh;
  padding: 0;
  border: none;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.match-wb-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.match-wb-dialog form {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}

.match-wb-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  border-bottom: 1px solid #e5e7eb;
}

.match-wb-dialog-head h3 {
  margin: 0;
  font-size: 16px;
}

.match-wb-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.match-wb-manual {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
}

.match-wb-manual label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #374151;
}

.match-wb-manual input {
  width: 88px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}

.match-wb-body {
  padding: 14px 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.45;
}

.match-wb-actions {
  padding: 10px 16px 14px;
  border-top: 1px solid #e5e7eb;
}

.match-wb-status {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 600;
}

.match-wb-status--ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.match-wb-status--fail {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.match-wb-status--warn {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.match-wb-section {
  margin-bottom: 14px;
}

.match-wb-section h4 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.match-wb-kv {
  margin: 0;
  padding: 0;
  list-style: none;
}

.match-wb-kv li {
  padding: 2px 0;
}

.match-wb-kv strong {
  color: #374151;
}

.match-wb-order-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.match-wb-order-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
  flex-shrink: 0;
}

.match-wb-order-meta {
  min-width: 0;
}

.match-wb-alt {
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  font-size: 12px;
}

.match-wb-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-wb-pick-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  background: #f9fafb;
}

.match-wb-pick-item:hover {
  border-color: #e91e8c;
}

.match-wb-pick-item input {
  margin-top: 4px;
  flex-shrink: 0;
}

.match-wb-pick-meta {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
}

.download-all-actions .match-wb-btn,
.download-all-actions .match-ozon-btn {
  margin: 0;
}

.messages-wrap {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, #dfe6ee 0%, #e8edf3 100%);
}

.scroll-to-bottom-btn {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 12;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 22px;
  background: var(--accent, #2f80ed);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(47, 128, 237, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  transition: transform 0.15s ease, opacity 0.15s ease, width 0.15s ease;
}

.scroll-to-bottom-btn--new {
  width: auto;
  min-width: 44px;
  max-width: calc(100% - 40px);
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
}

.scroll-to-bottom-label {
  white-space: nowrap;
}

.scroll-to-bottom-label[hidden],
.scroll-to-bottom-icon[hidden] {
  display: none !important;
}

.scroll-to-bottom-btn:hover {
  transform: scale(1.04);
}

.scroll-to-bottom-btn[hidden] {
  display: none !important;
}

.date-divider {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
}

.date-divider span {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
  color: #4b5563;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.bubble-row {
  display: flex;
  margin-bottom: 4px;
  width: 100%;
  min-width: 0;
}

.bubble-row.client {
  justify-content: flex-start;
}

.bubble-row.seller {
  justify-content: flex-end;
}

.bubble-wrap {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 8px;
  width: auto;
  max-width: 70%;
  min-width: 0;
  flex: 0 0 auto;
}

.bubble-row.client .bubble-wrap {
  flex-direction: row;
}

.bubble-row.seller .bubble-wrap {
  flex-direction: row-reverse;
}

.bubble {
  border-radius: 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.bubble.bubble--text-only {
  display: inline-block;
  width: auto;
  max-width: 100%;
  padding: 6px 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
  vertical-align: bottom;
}

.bubble-row.client .bubble {
  background: var(--client-bubble);
  border-bottom-left-radius: 4px;
}

.bubble-row.seller .bubble {
  background: var(--seller-bubble);
  border-bottom-right-radius: 4px;
}


.msg-meta {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
  padding-bottom: 1px;
  line-height: 1.2;
}

.msg-time {
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 0;
  flex-shrink: 0;
  white-space: nowrap;
  user-select: none;
  line-height: 1.2;
}

.msg-status {
  font-size: 13px;
  line-height: 1;
  letter-spacing: -0.12em;
  user-select: none;
  flex-shrink: 0;
}

.msg-status--sending,
.msg-status--sent {
  color: var(--muted);
  opacity: 0.85;
}

.msg-status--delivered {
  color: var(--accent-active, #2563eb);
  opacity: 1;
}

.msg-status--tg-sent,
.msg-status--tg-delivered,
.msg-status--tg-sending {
  color: #8696a4;
  opacity: 1;
}

.msg-status--tg-read {
  color: #53bdeb;
  opacity: 1;
}

.msg-tg-checks {
  letter-spacing: -0.2em;
}

.msg-tg-clock {
  width: 14px;
  height: 14px;
  display: block;
}

.msg-status--tg-sending .msg-tg-clock {
  animation: msg-tg-clock-spin 1.2s linear infinite;
}

@keyframes msg-tg-clock-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.bubble-wrap--text {
  align-items: flex-end;
  line-height: 0;
}

.bubble-wrap--text .bubble--text-only {
  line-height: 1.35;
  font-size: 14px;
}

.bubble-wrap--text .msg-time {
  line-height: 1.2;
  font-size: 11px;
  padding-bottom: 1px;
}

.bubble-wrap--file:has(.msg-file-card--image) {
  max-width: min(320px, 78%);
}

.bubble-wrap--file:not(:has(.msg-file-card--image)) {
  max-width: 70%;
}

.bubble-wrap--file .msg-time {
  line-height: 1.2;
  font-size: 11px;
  align-self: flex-end;
  padding-bottom: 1px;
}

.bubble-wrap--file .msg-file-card,
.bubble-wrap--file .msg-file-name,
.bubble-wrap--file .msg-file-size {
  line-height: 1.35;
}

.bubble-wrap--combo {
  align-items: flex-end;
}

.bubble-wrap--combo .msg-time {
  padding-bottom: 2px;
}

.bubble-wrap > .bubble:not(.bubble--text-only) {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
}

.bubble--media {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.bubble-row.client .bubble--media,
.bubble-row.seller .bubble--media {
  background: transparent;
}

.bubble--combo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: fit-content;
  max-width: 100%;
  padding: 8px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}

.bubble-row.client .bubble--combo {
  background: var(--client-bubble);
  border-bottom-left-radius: 4px;
}

.bubble-row.seller .bubble--combo {
  background: var(--seller-bubble);
  border-bottom-right-radius: 4px;
}

.bubble--combo .bubble-text {
  display: block;
  width: auto;
  max-width: 100%;
  padding: 0 2px;
  line-height: 1.35;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  box-sizing: border-box;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.bubble-text .msg-link,
.bubble--combo .msg-link,
.bubble--text-only .msg-link {
  text-decoration: underline;
  word-break: break-all;
}

.bubble-row.client .msg-link {
  color: #1e40af;
}

.bubble-row.client .msg-link:hover {
  color: #1d4ed8;
}

.bubble-row.seller .msg-link {
  color: #2563eb;
}

.bubble-row.seller .msg-link:hover {
  color: #1d4ed8;
}

.bubble--combo .msg-file-card:not(.msg-file-card--image) {
  max-width: 100%;
  border-color: #e5e7eb;
  box-shadow: none;
}

.msg-file-card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  min-height: 72px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.msg-file-card--image {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  max-width: min(300px, 100%);
  min-height: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.bubble-row.client .msg-file-card:not(.msg-file-card--image) {
  border-color: #c5d4e8;
}

.msg-file-card--image .msg-file-thumb {
  width: 100%;
  height: auto;
  min-height: 180px;
  max-height: 320px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
}

.msg-file-card--image .msg-file-thumb img {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: cover;
}

.msg-file-card--image .msg-file-actions {
  margin-top: 0;
  padding-left: 2px;
}

.msg-file-thumb {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 6px;
  overflow: hidden;
  background: #e5e7eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-file-thumb img {
  width: 100%;
  height: 100%;
  min-width: 56px;
  min-height: 56px;
  object-fit: cover;
  object-position: center center;
  display: block;
  background: #d1d5db;
}

.msg-file-thumb img:not([src]),
.msg-file-thumb img[src=""] {
  visibility: hidden;
}

.msg-file-thumb--loading::before,
.msg-file-thumb--failed::before {
  display: block;
}

.msg-file-thumb--loading::before {
  content: "";
  width: 22px;
  height: 22px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.msg-file-thumb--failed::before {
  content: "📷";
  font-size: 22px;
  line-height: 1;
  opacity: 0.55;
}

.msg-file-thumb--loading img,
.msg-file-thumb--failed img {
  display: none !important;
}

.msg-file-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.msg-file-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-file-size {
  font-size: 13px;
  color: #6b7280;
}

.msg-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.msg-file-btn {
  padding: 0;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.msg-file-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.msg-file-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

.msg-file-progress {
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-file-progress:not([hidden]) {
  display: inline;
}

.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  padding: 24px;
  cursor: zoom-out;
}

.media-lightbox[hidden] {
  display: none !important;
}

.media-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: default;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
  min-width: 0;
}

.attach-btn {
  font-size: 22px;
  cursor: pointer;
  padding: 6px 8px;
  line-height: 1;
}

#messageInput {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  max-height: 120px;
  font-family: inherit;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent-active);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.download-all-wrap {
  margin: 0 12px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.download-all-actions {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
}

.download-all-actions .download-all-btn,
.download-all-actions .fulfill-wb-btn,
.download-all-actions .download-all-retry-btn {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.download-all-retry-btn {
  flex-shrink: 0;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  background: #fffbeb;
  color: #b45309;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.download-all-retry-btn:hover:not(:disabled) {
  background: #fef3c7;
}

.download-all-retry-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.download-all-retry-btn[hidden] {
  display: none;
}

.download-all-open-btn {
  flex-shrink: 0;
  padding: 10px 14px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.download-all-open-btn:hover {
  background: #1d4ed8;
}

.download-all-open-btn[hidden] {
  display: none;
}

.download-all-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafbfc;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.download-all-btn--ready:not(:disabled) {
  border: 1px solid #2563eb;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1d4ed8;
}

.download-all-btn--ready:not(:disabled):hover {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
}

.download-all-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.download-all-progress {
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
  text-align: center;
  line-height: 1.35;
  min-height: 1.35em;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.download-all-progress:not([hidden]) {
  display: flex;
}

.download-all-progress-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.download-all-progress-text {
  min-width: 0;
}

.panel-templates {
  display: flex;
  flex-direction: column;
}

.templates-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.templates {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.templates-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.templates-send-hint {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.35;
}

.templates-send-hint.is-ready {
  color: #2563eb;
}

.btn-create-template {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent-active);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-create-template:hover {
  filter: brightness(1.05);
}

.template-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fafbfc;
  cursor: default;
  transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.15s ease;
}

.template-drag-handle {
  cursor: grab;
}

.template-drag-handle:active {
  cursor: grabbing;
}

.template-card.template-dragging {
  opacity: 0.55;
  transform: scale(0.98);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.template-card.template-drag-over {
  transform: translateY(6px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  border-color: #93c5fd;
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.template-drag-hint {
  flex-shrink: 0;
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  user-select: none;
  padding-top: 1px;
}

.template-card h4 {
  font-size: 13px;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.template-att {
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--border);
}

.template-att img {
  display: block;
  width: 100%;
  max-height: 72px;
  object-fit: cover;
  object-position: center center;
}

.template-att-file {
  padding: 6px 8px;
  font-size: 12px;
  color: #4b5563;
}

.template-atts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.template-att-video {
  padding: 6px 8px;
}

.template-files-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-files-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  font-size: 12px;
}

.template-file-remove {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.template-file-remove:hover {
  color: #ef4444;
}

.template-card p {
  font-size: 13px;
  color: #374151;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.template-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.template-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.template-actions button.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#editDialog {
  border: none;
  border-radius: 12px;
  padding: 20px;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

#editDialog form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#editDialog input,
#editDialog textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.dialog-actions-right {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.btn-delete {
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}

.btn-delete-small {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 5px;
}

.btn-delete:hover {
  background: #b91c1c;
}

.btn-dialog {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-dialog-primary {
  background: var(--accent-active);
  color: #fff;
}

.btn-dialog-primary:hover {
  filter: brightness(1.05);
}

.btn-dialog-secondary {
  background: #e5e7eb;
  color: #374151;
}

.btn-dialog-secondary:hover {
  background: #d1d5db;
}

.template-file-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.template-file-label span:first-child {
  font-weight: 500;
  color: #374151;
}

.template-file-name {
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
}

.template-file-preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  object-fit: contain;
}

.template-file-clear {
  align-self: flex-start;
  border: none;
  background: none;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.template-file-clear:hover {
  color: #111827;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
}

.toast[hidden] {
  display: none;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

.app-menubar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 0 10px;
  height: 28px;
  display: flex;
  align-items: center;
}

.app-menubar[hidden] {
  display: none !important;
}

.rocket-desktop .app-menubar {
  display: none !important;
}

.app-menu-file {
  position: relative;
}

.app-menu-trigger {
  border: none;
  background: transparent;
  font-size: 13px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
}

.app-menu-trigger:hover {
  background: rgba(0, 0, 0, 0.06);
}

.app-menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  z-index: 200;
}

.app-menu-dropdown[hidden] {
  display: none !important;
}

.app-menu-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

.app-menu-dropdown button:hover {
  background: rgba(47, 128, 237, 0.1);
}

body.browser-with-menu {
  display: flex;
  flex-direction: column;
}

body.browser-with-menu .app {
  flex: 1;
  min-height: 0;
  height: auto;
}

.cache-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.cache-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.cache-dialog form {
  padding: 20px 22px 18px;
}

.cache-dialog h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.cache-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.cache-settings-label {
  font-size: 14px;
  font-weight: 500;
}

.cache-settings-row select {
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.cache-settings-hint {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.cache-settings-clear {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-cache-clear {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e57373;
  background: #fff5f5;
  color: #c62828;
  font-size: 14px;
  cursor: pointer;
}

.btn-cache-clear:hover {
  background: #ffebee;
}

.cache-dialog-confirm .cache-confirm-text {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
}

.btn-dialog-danger {
  background: #e53935;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-dialog-danger:hover {
  background: #c62828;
}

.media-context-menu {
  position: fixed;
  z-index: 12000;
  min-width: 220px;
  padding: 4px 0;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.media-context-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  color: #111827;
  cursor: pointer;
}

.media-context-menu-item:hover,
.media-context-menu-item:focus {
  background: #eff6ff;
  color: #1d4ed8;
  outline: none;
}

.media-context-menu-item[data-action="delete-me"],
.media-context-menu-item[data-action="delete-all"] {
  color: #b91c1c;
}

.media-context-menu-item[data-action="delete-me"]:hover,
.media-context-menu-item[data-action="delete-me"]:focus,
.media-context-menu-item[data-action="delete-all"]:hover,
.media-context-menu-item[data-action="delete-all"]:focus {
  background: #fef2f2;
  color: #991b1b;
}

.media-context-menu-sep {
  height: 1px;
  margin: 4px 0;
  background: #e5e7eb;
}

.edit-message-dialog {
  width: min(480px, calc(100vw - 32px));
  border: none;
  border-radius: 12px;
  padding: 20px;
}

.edit-message-dialog h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.edit-message-dialog textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
  min-height: 100px;
}

.msg-edited-label {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

.max-auth-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 16px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.max-auth-panel:not([hidden]) {
  display: block;
}

.max-auth-card {
  max-width: 360px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.max-auth-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

.max-auth-subtitle {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.max-auth-status {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #4b5563;
}

.max-auth-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #6b7280;
}

.max-auth-qr {
  text-align: center;
}

.max-auth-qr-img {
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 8px;
}

.max-auth-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: #2563eb;
  word-break: break-all;
}

.max-auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.max-auth-input {
  flex: 1;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

.max-auth-password-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.max-auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.max-auth-browser {
  padding-top: 4px;
  border-top: 1px solid #e5e7eb;
}

.max-auth-refresh {
  align-self: flex-start;
  border: none;
  background: none;
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.max-auth-refresh:hover {
  text-decoration: underline;
}

.panel-chats.max-auth-mode .chat-list,
.panel-chats.max-auth-mode .chat-toolbar-row,
.panel-chats.max-auth-mode .chat-search,
.panel-chats.tg-auth-mode .chat-list,
.panel-chats.tg-auth-mode .chat-toolbar-row,
.panel-chats.tg-auth-mode .chat-search {
  display: none;
}
