
:root {
  color-scheme: dark;
  --tg-bg: var(--tg-theme-bg-color, #0e1621);
  --tg-secondary: var(--tg-theme-secondary-bg-color, #17212b);
  --tg-text: var(--tg-theme-text-color, #eff6fd);
  --tg-hint: var(--tg-theme-hint-color, #8192a5);
  --tg-link: var(--tg-theme-link-color, #2ea6ff);
  --tg-button: var(--tg-theme-button-color, #2ea6ff);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --bg: var(--tg-bg);
  --sidebar: var(--tg-secondary);
  --sidebar-2: color-mix(in srgb, var(--tg-secondary) 88%, #000 12%);
  --surface: color-mix(in srgb, var(--tg-bg) 90%, #000 10%);
  --surface-2: color-mix(in srgb, var(--tg-secondary) 92%, #fff 8%);
  --surface-3: color-mix(in srgb, var(--tg-secondary) 85%, #fff 15%);
  --line: color-mix(in srgb, var(--tg-text) 14%, transparent);
  --line-strong: color-mix(in srgb, var(--tg-text) 24%, transparent);
  --text: var(--tg-text);
  --soft: color-mix(in srgb, var(--tg-text) 78%, var(--tg-hint) 22%);
  --muted: var(--tg-hint);
  --accent: var(--tg-button);
  --accent-2: #48d3b5;
  --rio-accent: #e05252;
  --warn: #f4b84d;
  --danger: #ff6f8d;
  --violet: #9a91ff;
  --incoming: #1f2c3a;
  --outgoing: #2b5278;
  --outgoing-2: #2f6ea4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #ffffff;
  overscroll-behavior: none;
}

body.telegram-host {
  color: var(--text);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 180px),
    linear-gradient(135deg, color-mix(in srgb, var(--accent-2) 7%, transparent), transparent 520px),
    var(--bg);
}

body:not(.telegram-host) .empty-state h2 {
  color: #111827;
}

body:not(.telegram-host) .empty-state p,
body:not(.telegram-host) .empty-mark {
  color: #6b7280;
}

body:not(.telegram-host) .empty-mark {
  border-color: rgba(17, 24, 39, 0.12);
  background: rgba(17, 24, 39, 0.04);
}

.external-browser-page {
  display: none;
}

body.external-browser-host {
  background: #ffffff;
  overflow: hidden;
}

body.external-browser-host .external-browser-page {
  display: block;
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 99999;
}

body.external-browser-host .app-shell,
body.external-browser-host .toast,
body.external-browser-host .account-picker-panel,
body.external-browser-host .settings-panel,
body.external-browser-host .sender-panel,
body.external-browser-host .binds-panel,
body.external-browser-host .banned-panel {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/*
  Layout contract (access-stable-v17):
  - .inbox-pane, .pane-splitter, and .thread-pane are SIBLINGS inside .app-shell (never nested).
  - Desktop (≥881px): flex row, resizable sidebar + growing thread. NEVER position:absolute.
  - Inbox width via --inbox-pane-width (drag splitter; persisted in localStorage).
  - Mobile (≤880px): one pane at a time via display:none (still no absolute stacking); splitter hidden.
  - .detail-open is mobile-only; desktop CSS ignores it for visibility.
*/
.app-shell {
  --inbox-pane-width: clamp(280px, 36vw, 420px);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.045);
  background: var(--bg);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
  isolation: isolate;
  overflow: hidden;
}

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

.inbox-pane,
.thread-pane {
  position: relative;
  inset: auto;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  z-index: auto;
}

.inbox-pane {
  position: relative;
  display: grid;
  flex: 0 0 var(--inbox-pane-width);
  width: var(--inbox-pane-width);
  min-width: 280px;
  max-width: 560px;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tg-text) 3.5%, transparent), transparent 160px),
    var(--sidebar);
  backdrop-filter: blur(20px) saturate(1.18);
}

.pane-splitter {
  display: none;
  position: relative;
  flex: 0 0 6px;
  width: 6px;
  margin: 0 -1px;
  padding: 0;
  border: 0;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
  background: transparent;
  align-self: stretch;
}

.pane-splitter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: transparent;
  transition: background 120ms ease, width 120ms ease;
}

.pane-splitter:hover::before,
.pane-splitter:focus-visible::before,
.pane-splitter.is-dragging::before {
  width: 2px;
  background: color-mix(in srgb, var(--accent) 72%, transparent);
}

.pane-splitter:focus-visible {
  outline: none;
}

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

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

.main-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
}

.main-tab {
  flex: 1;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.main-tab.active {
  color: var(--tg-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.main-tab[hidden] {
  display: none !important;
}

.chats-view {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
}

.chats-view[hidden] {
  display: none !important;
}

.logs-pane {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.logs-pane[hidden] {
  display: none !important;
}

.ops-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.ops-pane[hidden] {
  display: none !important;
}

.ops-pane-title {
  margin: 0;
  flex: 1 1 auto;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ops-alerts {
  padding: 0 12px 10px;
  display: grid;
  gap: 6px;
}

.ops-alerts[hidden] {
  display: none !important;
}

.ops-alert {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-word;
}

.ops-alert[data-level="warning"] {
  color: #ffd27a;
  border-color: color-mix(in srgb, #ffd27a 45%, var(--line));
  background: color-mix(in srgb, #ffd27a 10%, transparent);
}

.ops-alert[data-level="critical"] {
  color: #ff8d98;
  border-color: color-mix(in srgb, #ff8d98 50%, var(--line));
  background: color-mix(in srgb, #ff8d98 12%, transparent);
}

.ops-funnel {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.ops-funnel span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.ops-funnel span[data-strong="true"] {
  color: #7ce7c0;
  border-color: color-mix(in srgb, #7ce7c0 40%, var(--line));
}

.sender-logs-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.sender-logs-pane[hidden] {
  display: none !important;
}

.sender-logs-queue[hidden],
.logs-list[hidden] {
  display: none !important;
}

.sender-logs-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0 12px 10px;
}

.sender-logs-tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--tg-text) 3.5%, transparent);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sender-logs-tab.active {
  color: var(--tg-text);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.sender-logs-queue {
  overflow: auto;
  padding: 0 12px 16px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.sender-logs-section {
  display: grid;
  gap: 8px;
}

.sender-logs-section-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sender-logs-job {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--tg-text) 3.5%, transparent);
  font-size: 12px;
  line-height: 1.35;
}

.sender-logs-job[data-overdue="true"] {
  border-color: color-mix(in srgb, #ffd27a 45%, var(--line));
}

.sender-logs-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.logs-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}

.logs-back-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}

.logs-queue-stats {
  padding: 0 12px 10px;
  display: grid;
  gap: 8px;
}

.logs-queue-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.logs-queue-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--tg-text) 3.5%, transparent);
}

.logs-queue-card strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.logs-queue-card small {
  color: var(--muted);
  font-size: 11px;
}

.logs-queue-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.logs-filter {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
  font-size: 11px;
  color: var(--muted);
}

.logs-filter select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  color: var(--tg-text);
  padding: 0 10px;
  font: inherit;
}

.logs-refresh-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  color: var(--tg-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.logs-list {
  overflow: auto;
  padding: 0 12px 16px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.log-entry {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tg-text) 3.5%, transparent);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.log-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.log-entry-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-entry-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.log-entry-badge[data-category="campaign"] {
  color: #8fd3ff;
  background: color-mix(in srgb, #8fd3ff 14%, transparent);
}

.log-entry-badge[data-category="parser"] {
  color: #b6a0ff;
  background: color-mix(in srgb, #b6a0ff 14%, transparent);
}

.log-entry-badge[data-category="auto_reply"] {
  color: #7ce7c0;
  background: color-mix(in srgb, #7ce7c0 14%, transparent);
}

.log-entry-badge[data-category="job"] {
  color: #ffd27a;
  background: color-mix(in srgb, #ffd27a 14%, transparent);
}

.log-entry-badge[data-category="error"] {
  color: #ff8d98;
  background: color-mix(in srgb, #ff8d98 14%, transparent);
}

.log-entry-badge[data-category="account"] {
  color: #d0d5df;
  background: color-mix(in srgb, #d0d5df 14%, transparent);
}

.log-entry-badge[data-status="queued"] {
  color: #8fd3ff;
  background: color-mix(in srgb, #8fd3ff 14%, transparent);
}

.log-entry-badge[data-status="running"] {
  color: #7ce7c0;
  background: color-mix(in srgb, #7ce7c0 14%, transparent);
}

.log-entry-badge[data-status="retry"] {
  color: #ffd27a;
  background: color-mix(in srgb, #ffd27a 14%, transparent);
}

.log-entry-badge[data-status="failed"] {
  color: #ff8d98;
  background: color-mix(in srgb, #ff8d98 14%, transparent);
}

.log-entry[data-error="true"] {
  border-color: color-mix(in srgb, #ff8d98 45%, var(--line));
  background: color-mix(in srgb, #ff8d98 8%, transparent);
}

.log-entry-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--tg-text);
  word-break: break-word;
}

.log-entry-type {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.app-shell.logs-view-active .thread-pane,
.app-shell.ops-monitor-view-active .thread-pane,
.app-shell.sender-logs-view-active .thread-pane {
  display: none;
}

.app-shell.logs-view-active .inbox-pane,
.app-shell.ops-monitor-view-active .inbox-pane,
.app-shell.sender-logs-view-active .inbox-pane {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-right: 0;
}

.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 8px;
  padding-right: calc(16px + var(--safe-right));
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding-right: 2px;
}

.next-first-message-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.next-first-message-pill[hidden] {
  display: none !important;
}

.next-first-message-pill:hover,
.next-first-message-pill:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.next-first-message-pill.is-sending {
  color: var(--soft);
  border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

.next-first-message-pill-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  opacity: 0.88;
}

.next-first-message-pill-icon path,
.next-first-message-pill-icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.next-first-message-pill-time {
  min-width: 2.8em;
  text-align: center;
  line-height: 1;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  opacity: 0.92;
}

.app-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 0 14px 10px;
}

.account-picker-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--tg-text) 5%, transparent);
  text-align: left;
}

.account-picker-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 620;
}

.account-picker-chevron {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.sender-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.sender-pill.running {
  color: var(--soft);
  border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
}

.sender-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.sender-pill.running .sender-dot {
  background: var(--accent-2);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent-2) 60%, transparent);
}

.sender-pill.queue-warn,
.sender-pill.queue-delayed {
  border-color: color-mix(in srgb, #ff9f0a 45%, transparent);
}

.sender-pill.queue-delayed .sender-dot {
  background: #ff9f0a;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 68, 68, 0.32);
  border-radius: 8px;
  color: white;
  background:
    linear-gradient(145deg, rgba(46, 166, 255, 0.96), rgba(72, 211, 181, 0.62)),
    #2ea6ff;
  box-shadow: 0 12px 28px rgba(46, 166, 255, 0.18);
  font-weight: 850;
}

.head-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: #7cd7ff;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1;
}

.icon-button,
.status-tab,
.quick-button,
.copy-button,
.send-button,
.back-button,
.open-link {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.icon-button,
.copy-button,
.back-button,
.open-link {
  border-radius: 999px;
}

.send-button {
  border-radius: 14px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.icon-button.refreshing {
  pointer-events: none;
  opacity: 0.82;
}

.icon-button.refreshing svg {
  animation: spinRefresh 900ms linear infinite;
  transform-origin: center;
}

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

@media (min-width: 881px) {
  .app-shell {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
  }

  .inbox-pane,
  .thread-pane {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    height: auto !important;
    overflow: hidden !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: auto !important;
  }

  .inbox-pane {
    display: grid !important;
    flex: 0 0 var(--inbox-pane-width) !important;
    width: var(--inbox-pane-width) !important;
    min-width: 280px !important;
    max-width: 560px !important;
  }

  .pane-splitter {
    display: block !important;
    position: relative !important;
    flex: 0 0 6px !important;
    width: 6px !important;
    align-self: stretch !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .thread-pane {
    display: grid !important;
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  /* detail-open is mobile-only; never hide/overlap panes on desktop */
  .app-shell.detail-open .inbox-pane,
  .app-shell:not(.detail-open) .inbox-pane {
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    inset: auto !important;
    flex: 0 0 var(--inbox-pane-width) !important;
    width: var(--inbox-pane-width) !important;
    min-width: 280px !important;
    max-width: 560px !important;
    overflow: hidden !important;
    z-index: auto !important;
  }

  .app-shell.detail-open .thread-pane,
  .app-shell:not(.detail-open) .thread-pane {
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    inset: auto !important;
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: hidden !important;
    z-index: auto !important;
  }

  .app-shell.logs-view-active .thread-pane,
  .app-shell.ops-monitor-view-active .thread-pane,
  .app-shell.sender-logs-view-active .thread-pane {
    display: none !important;
  }

  .app-shell.logs-view-active .pane-splitter,
  .app-shell.ops-monitor-view-active .pane-splitter,
  .app-shell.sender-logs-view-active .pane-splitter {
    display: none !important;
  }

  .app-shell.logs-view-active .inbox-pane,
  .app-shell.ops-monitor-view-active .inbox-pane,
  .app-shell.sender-logs-view-active .inbox-pane {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    position: relative !important;
    inset: auto !important;
    border-right: 0 !important;
  }
}

.icon-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.icon-button:hover,
.quick-button:hover,
.copy-button:hover,
.back-button:hover,
.open-link:hover {
  border-color: rgba(33, 160, 255, 0.56);
  background: rgba(33, 160, 255, 0.12);
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0;
}

.stats-popover {
  margin: 0 14px 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--tg-secondary) 92%, #000 8%);
  box-shadow: var(--shadow);
}

.stats-popover[hidden] {
  display: none !important;
}

.icon-button[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
}

.overview-strip div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
}

.overview-strip span {
  display: block;
  margin-bottom: 2px;
  font-size: 16px;
  font-weight: 800;
}

.overview-strip small {
  color: var(--muted);
  font-size: 12px;
}

.account-picker-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.search-box {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin: 0 14px 10px;
  padding: 0 12px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
}

.search-box input {
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-box:focus-within {
  border-color: rgba(33, 160, 255, 0.72);
  color: var(--accent);
}

.account-picker-panel,
.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 35;
}

.account-picker-panel[hidden],
.settings-panel[hidden] {
  display: none !important;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 13, 0.68);
  backdrop-filter: blur(10px);
}

.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(82dvh, 640px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  color: var(--text);
  background: var(--sidebar-2);
  box-shadow: var(--shadow);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
}

.account-picker-list {
  min-height: 0;
  overflow: auto;
  padding: 8px 12px calc(12px + var(--safe-bottom));
}

.account-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.account-picker-item:hover {
  background: color-mix(in srgb, var(--tg-text) 5%, transparent);
}

.account-picker-item.active {
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.account-picker-item-main {
  min-width: 0;
}

.account-picker-item-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 680;
}

.account-picker-item-main small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.account-picker-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: transparent;
}

.account-picker-item.active .account-picker-check {
  border-color: var(--accent);
  color: var(--tg-button-text);
  background: var(--accent);
}

.settings-body {
  overflow: auto;
  padding: 8px 12px calc(16px + var(--safe-bottom));
}

.settings-group {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
}

.settings-group-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settings-campaign-row {
  display: grid;
  gap: 10px;
}

.settings-campaign-status {
  color: var(--soft);
  font-size: 14px;
  font-weight: 650;
}

.settings-campaign-status.running {
  color: var(--accent-2);
}

.settings-campaign-actions {
  display: flex;
  gap: 8px;
}

.settings-action-btn {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--tg-text) 5%, transparent);
  font-weight: 700;
}

.settings-action-btn.primary {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--tg-button-text);
  background: var(--accent);
}

.settings-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  margin-bottom: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  font-size: 15px;
  font-weight: 620;
  text-align: left;
}

.settings-menu-item svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.account-filter-shell {
  display: none;
}

.account-scroll,
.account-filter,
.campaign-bar,
.banned-toggle {
  display: none !important;
}

.banned-panel,
.binds-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.banned-panel[hidden],
.binds-panel[hidden] {
  display: none !important;
}

.banned-accounts,
.binds-body {
  min-height: 0;
  overflow: auto;
  padding: 0 18px 18px;
}

.banned-account {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.banned-account-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.banned-account-copy {
  min-width: 0;
}

.banned-account-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.banned-account-head p,
.banned-account-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.banned-account-head p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.banned-delete-btn {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 42%, transparent);
  border-radius: 8px;
  color: #ffe4eb;
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  white-space: nowrap;
}

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

.binds-form {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.binds-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.binds-form input,
.binds-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  outline: none;
}

.binds-form textarea {
  resize: vertical;
  min-height: 72px;
}

.binds-list {
  display: grid;
  gap: 8px;
}

.bind-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
}

.bind-item-copy {
  min-width: 0;
}

.bind-item-copy h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.bind-item-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bind-delete-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--soft);
  background: transparent;
  white-space: nowrap;
}

.binds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.bind-chip {
  max-width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bind-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.status-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 0 14px 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--tg-text) 4%, transparent);
  overflow: visible;
}

.status-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: 8px;
  border-color: transparent;
  color: var(--soft);
  background: transparent;
  font-size: 11px;
  line-height: 1.1;
}

.status-tab.active {
  color: white;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.status-tab[data-status="new"].active {
  border-color: color-mix(in srgb, var(--rio-accent) 50%, transparent);
  background: color-mix(in srgb, var(--rio-accent) 14%, transparent);
}

.status-tab[data-status="contact_received"].active {
  border-color: rgba(72, 211, 181, 0.58);
  background: rgba(72, 211, 181, 0.14);
}

.status-tab[data-status="in_work"].active {
  border-color: rgba(244, 184, 77, 0.58);
  background: rgba(244, 184, 77, 0.14);
}

.status-tab[data-status="ignored_closed"].active {
  border-color: rgba(255, 111, 141, 0.54);
  background: rgba(255, 111, 141, 0.12);
}

.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #e8f5ff;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 760;
}

.status-tab[data-status="new"] .tab-count,
.badge.new-badge,
.badge.blue {
  color: #e6f6ff;
  background: rgba(46, 166, 255, 0.24);
}

.status-tab[data-status="contact_received"] .tab-count,
.badge.green {
  color: #dcfff7;
  background: rgba(72, 211, 181, 0.22);
}

.status-tab[data-status="in_work"] .tab-count,
.badge.amber {
  color: #fff2d5;
  background: rgba(244, 184, 77, 0.22);
}

.status-tab[data-status="ignored_closed"] .tab-count {
  color: #ffe4eb;
  background: rgba(255, 111, 141, 0.2);
}

.badge.red {
  color: #ffe4eb;
  background: rgba(255, 111, 141, 0.22);
}

.badge.muted {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.badge.folder-badge {
  color: #dfe7f7;
  background: rgba(138, 156, 190, 0.24);
}

.chat-list {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px 14px;
  background: var(--sidebar);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chat-list-date-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 12px 12px 6px;
  border: 0;
  color: rgba(176, 192, 216, 0.78);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(18, 24, 34, 0.98) 0%, rgba(18, 24, 34, 0.92) 72%, rgba(18, 24, 34, 0) 100%);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.chat-list-date-header::after {
  content: "";
  display: block;
  height: 1px;
  margin-top: 8px;
  background: linear-gradient(90deg, rgba(138, 156, 190, 0.34), rgba(138, 156, 190, 0));
}

.chat-list-date-header:first-child {
  padding-top: 8px;
}

.chat-row {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 82px;
  margin: 0 0 4px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: inherit;
  text-align: left;
  background: transparent;
  box-shadow: inset 0 0 0 rgba(46, 166, 255, 0);
  overflow: hidden;
}

.chat-row:hover {
  background: rgba(255, 255, 255, 0.052);
}

.chat-row.active {
  border-color: rgba(33, 160, 255, 0.48);
  background: linear-gradient(90deg, rgba(46, 166, 255, 0.22), rgba(46, 166, 255, 0.09));
  box-shadow: inset 3px 0 0 var(--accent);
}

.chat-row.status-contact-received.active {
  border-color: rgba(72, 211, 181, 0.44);
  background: linear-gradient(90deg, rgba(72, 211, 181, 0.18), rgba(72, 211, 181, 0.07));
  box-shadow: inset 3px 0 0 var(--accent-2);
}

.chat-row.status-in-work.active {
  border-color: rgba(244, 184, 77, 0.42);
  background: linear-gradient(90deg, rgba(244, 184, 77, 0.17), rgba(244, 184, 77, 0.065));
  box-shadow: inset 3px 0 0 var(--warn);
}

.chat-row.status-ignored-closed.active {
  border-color: rgba(255, 111, 141, 0.42);
  background: linear-gradient(90deg, rgba(255, 111, 141, 0.15), rgba(255, 111, 141, 0.06));
  box-shadow: inset 3px 0 0 var(--danger);
}

.thumb {
  display: grid;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: #e4f4ff;
  background:
    linear-gradient(145deg, rgba(46, 166, 255, 0.26), rgba(154, 145, 255, 0.18)),
    #243445;
  font-weight: 860;
}

.thumb {
  width: 52px;
  height: 52px;
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-main {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.row-head,
.row-meta,
.row-flags {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.row-head,
.row-meta {
  justify-content: space-between;
  overflow: hidden;
}

.row-title,
.row-message,
.row-account,
.row-product {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-title {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 780;
}

.row-time {
  flex: 0 0 auto;
  white-space: nowrap;
}

.row-message {
  margin: 5px 0 7px;
  color: var(--muted);
  font-size: 13px;
}

.row-account,
.row-product,
.row-time {
  color: var(--muted);
  font-size: 12px;
}

.row-account {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  padding: 2px 7px;
  border-radius: 999px;
  color: #dff7ff;
  background: rgba(46, 166, 255, 0.14);
}

.row-product {
  min-width: 0;
  flex: 1 1 auto;
}

.row-flags {
  flex: 0 1 auto;
  max-width: 42%;
  overflow: hidden;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  min-height: 21px;
  padding: 0 7px;
  border-radius: 999px;
  color: #dfefff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-pane {
  position: relative;
  z-index: auto;
  display: grid;
  flex: 1 1 0;
  width: auto;
  max-width: none;
  min-width: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: #0e1621;
  isolation: isolate;
}

.thread-pane.has-auto-reply-banner {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.auto-reply-banner {
  position: relative;
  z-index: 3;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(23, 33, 43, 0.96);
  color: #d7e3f4;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.35;
}

.auto-reply-banner.state-pending {
  color: #ffd98a;
  background: rgba(255, 193, 77, 0.1);
}

.auto-reply-banner.state-waiting-seller {
  color: #9ed0ff;
  background: rgba(110, 181, 255, 0.1);
}

.auto-reply-banner.state-awaiting-first-reply {
  color: #c8d0dc;
  background: rgba(148, 163, 184, 0.1);
}

.auto-reply-banner.state-all-sent {
  color: #9ef0c8;
  background: rgba(78, 214, 154, 0.1);
}

.auto-reply-banner.state-all-sent-no-email {
  color: #ffe0a8;
  background: rgba(255, 193, 77, 0.08);
}

.auto-reply-banner.state-paused {
  color: #ffb4c7;
  background: rgba(255, 111, 141, 0.12);
}

.thread-head {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #17212b;
  backdrop-filter: blur(20px) saturate(1.12);
}

.back-button {
  display: none;
  width: 40px;
  height: 40px;
  place-items: center;
}

.thread-title {
  min-width: 0;
}

.thread-title h2 {
  overflow: hidden;
  margin: 0 0 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.thread-title p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.account-warning {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  margin-top: 7px;
  padding: 0 9px;
  border-radius: 999px;
  color: #ffe4eb;
  background: rgba(255, 111, 141, 0.16);
  font-size: 12px;
  font-weight: 780;
}

.thread-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.thread-actions .meta-chip {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
}

.thread-actions .meta-chip span {
  display: none;
}

.meta-chip,
.icon-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--soft);
  background: color-mix(in srgb, var(--tg-text) 5%, transparent);
  font-size: 12px;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.meta-chip svg,
.icon-tool svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.meta-chip:hover,
.icon-tool:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.meta-chip.email {
  border-color: color-mix(in srgb, var(--accent-2) 35%, transparent);
  color: color-mix(in srgb, var(--accent-2) 85%, white 15%);
}

.meta-chip.listing {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: color-mix(in srgb, var(--accent) 85%, white 15%);
}

.meta-chip.client {
  border-color: color-mix(in srgb, var(--violet) 35%, transparent);
  color: color-mix(in srgb, var(--violet) 85%, white 15%);
}

.copy-button,
.open-link {
  display: none;
}

.messages {
  position: relative;
  z-index: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #0e1621;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  contain: layout paint;
}

.day-separator {
  display: flex;
  justify-content: center;
  margin: 2px 0 14px;
}

.day-separator span {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(14, 22, 33, 0.82);
  font-size: 12px;
}

.message {
  display: grid;
  gap: 6px;
  width: min(72%, 680px);
  min-width: 0;
  margin: 0 0 10px;
}

.bubble {
  max-width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.message.incoming {
  margin-right: auto;
  justify-items: start;
}

.message.incoming .bubble {
  background: linear-gradient(180deg, rgba(34, 49, 63, 0.98), rgba(28, 40, 52, 0.98));
}

.message.outgoing {
  margin-left: auto;
  justify-self: end;
  justify-items: end;
}

.message.outgoing .bubble {
  border-color: rgba(125, 198, 255, 0.22);
  background: linear-gradient(180deg, rgba(53, 123, 177, 0.98), rgba(43, 82, 120, 0.98));
}

.message.outgoing.pending .bubble {
  opacity: 0.72;
  border-style: dashed;
}

.message.outgoing.failed .bubble {
  border-color: rgba(255, 120, 120, 0.45);
  background: linear-gradient(180deg, rgba(120, 52, 52, 0.98), rgba(92, 38, 38, 0.98));
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.translation {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #d4e2ed;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.4;
}

.message-meta {
  color: var(--muted);
  font-size: 11px;
}

.composer-wrap {
  position: relative;
  z-index: 4;
  padding: 12px 18px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: #111b25;
  backdrop-filter: blur(20px) saturate(1.14);
}

.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 6px;
  border: 1px solid rgba(196, 216, 235, 0.11);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022)),
    rgba(7, 12, 18, 0.48);
}

.icon-tool {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 11px;
}

.icon-tool.active {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: white;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.icon-tool.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: #ffd8e2;
}

.icon-tool.danger:hover {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.status-picker {
  position: relative;
  margin-right: auto;
}

.status-picker-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  display: grid;
  gap: 4px;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--sidebar-2);
  box-shadow: var(--shadow);
}

.status-picker-menu[hidden] {
  display: none !important;
}

.status-picker-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--soft);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.status-picker-menu button:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.status-picker-menu button.active {
  color: white;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.status-picker-menu button.danger.active {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
}

.quick-actions {
  display: none;
}

.quick-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border-color: transparent;
  color: var(--soft);
  background: transparent;
  font-size: 13px;
}

.quick-button.active {
  border-color: rgba(46, 166, 255, 0.42);
  color: white;
  background:
    linear-gradient(180deg, rgba(46, 166, 255, 0.28), rgba(46, 166, 255, 0.16)),
    rgba(46, 166, 255, 0.1);
}

.quick-button.danger {
  border-color: rgba(255, 111, 141, 0.3);
  color: #ffdede;
}

.quick-button.danger:hover {
  border-color: rgba(255, 111, 141, 0.5);
  background: rgba(255, 111, 141, 0.12);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 144px;
  resize: none;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  outline: none;
  background: rgba(8, 13, 20, 0.58);
  line-height: 1.38;
}

.composer textarea:focus {
  border-color: rgba(33, 160, 255, 0.76);
}

.send-button {
  display: grid;
  width: 48px;
  height: 46px;
  place-items: center;
  border-color: rgba(33, 160, 255, 0.68);
  color: white;
  background: linear-gradient(145deg, #2ea6ff, #1b8de4);
  box-shadow: 0 12px 26px rgba(46, 166, 255, 0.22);
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.empty-state,
.locked-state {
  display: grid;
  min-height: 100%;
  place-content: center;
  padding: 32px;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  margin: 0 auto 18px;
  border: 1px solid rgba(33, 160, 255, 0.32);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(33, 160, 255, 0.12);
}

.empty-state h2,
.locked-state h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.empty-state p,
.locked-state p,
.muted {
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 20;
  max-width: min(460px, calc(100vw - 32px));
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: rgba(15, 22, 31, 0.98);
  box-shadow: var(--shadow);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sender-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.sender-panel[hidden] {
  display: none !important;
}

.sender-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 13, 0.68);
  backdrop-filter: blur(10px);
}

.sender-sheet {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(720px, calc(100vw - 24px));
  max-height: min(780px, calc(100dvh - 28px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(46, 166, 255, 0.1), transparent 180px),
    var(--sidebar-2);
  box-shadow: var(--shadow);
}

.sender-sheet-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 18px 18px 12px;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.sender-sheet-head h2 {
  margin: 0;
  font-size: 24px;
}

.sender-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px 14px;
}

.sender-summary-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.sender-summary-item span {
  display: block;
  font-size: 20px;
  font-weight: 850;
}

.sender-summary-item small {
  color: var(--muted);
  font-size: 12px;
}

.sender-accounts {
  min-height: 0;
  overflow: auto;
  padding: 0 18px 18px;
}

.sender-account {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.sender-account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sender-account-title {
  min-width: 0;
}

.sender-account-title h3 {
  overflow: hidden;
  margin: 0 0 4px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.sender-account-title p,
.sender-account-stats {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.sender-mode {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.sender-mode button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.045);
}

.sender-mode button.active {
  border-color: rgba(46, 166, 255, 0.62);
  color: white;
  background: rgba(46, 166, 255, 0.18);
}

.sender-mode button[data-account-mode="full_paused"].active {
  border-color: rgba(255, 111, 141, 0.52);
  background: rgba(255, 111, 141, 0.14);
}

.sender-delay {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.sender-delay label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.sender-delay input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  outline: none;
}

.sender-delay input:focus {
  border-color: rgba(46, 166, 255, 0.66);
}

.sender-delay button {
  height: 36px;
  border: 1px solid rgba(46, 166, 255, 0.44);
  border-radius: 8px;
  padding: 0 12px;
  color: white;
  background: rgba(46, 166, 255, 0.18);
}

.sender-categories {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.sender-cat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 2px 0;
  font-weight: 700;
  font-size: 13px;
  text-align: left;
}

.sender-cat-toggle > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sender-cat-count {
  margin-left: 8px;
  flex: none;
}

.sender-cat-caret {
  margin-left: auto;
  flex: none;
  color: var(--muted);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.sender-categories.collapsed .sender-cat-caret {
  transform: rotate(-90deg);
}

.sender-cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.sender-categories.collapsed .sender-cat-chips {
  display: none;
}

.cat-chip {
  cursor: pointer;
  border: 0;
  font: inherit;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-chip.off {
  opacity: 0.55;
}

.cat-chip[disabled] {
  cursor: default;
  opacity: 0.4;
}

.sender-cat-empty {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 880px) {
  body {
    overflow: hidden;
  }

  /* Mobile: one full-bleed pane in normal flow — never absolute stack / overlay */
  .app-shell {
    display: flex !important;
    flex-direction: column !important;
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    overflow: hidden;
    border-left: 0;
    border-right: 0;
  }

  .inbox-pane,
  .thread-pane {
    position: relative !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    flex: 1 1 auto;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    z-index: auto !important;
  }

  .pane-splitter {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    width: 0 !important;
    flex: 0 0 0 !important;
  }

  .inbox-pane {
    display: grid !important;
    visibility: visible;
    pointer-events: auto;
    border-right: 0;
  }

  .chats-view,
  .status-tabs,
  .toolbar-row,
  .chat-list,
  .search-box {
    min-width: 0;
    max-width: 100%;
  }

  .thread-pane {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
  }

  /* Mobile list-only: inbox full-bleed, thread out of flow */
  .app-shell:not(.detail-open) .thread-pane {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .app-shell:not(.detail-open) .inbox-pane {
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Mobile detail-open: thread full-bleed, inbox out of flow (never overlap) */
  .app-shell.detail-open .inbox-pane {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .app-shell.detail-open .thread-pane {
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .app-shell.logs-view-active .thread-pane,
  .app-shell.ops-monitor-view-active .thread-pane,
  .app-shell.sender-logs-view-active .thread-pane {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  .app-shell.logs-view-active .inbox-pane,
  .app-shell.ops-monitor-view-active .inbox-pane,
  .app-shell.sender-logs-view-active .inbox-pane {
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    visibility: visible !important;
    pointer-events: auto !important;
    border-right: 0;
  }

  .back-button {
    display: grid;
  }
}

@supports (height: 100svh) {
  .app-shell {
    height: 100svh;
  }
}

@media (max-width: 560px) {
  .inbox-head {
    padding: 12px 12px 8px;
    padding-right: calc(12px + var(--safe-right));
  }

  .head-actions {
    gap: 4px;
  }

  .next-first-message-pill {
    min-height: 32px;
    padding: 0 7px;
    font-size: 11px;
  }

  .next-first-message-pill-icon {
    width: 12px;
    height: 12px;
  }

  .app-title {
    font-size: 18px;
  }

  .toolbar-row {
    padding-inline: 10px;
  }

  .sender-pill {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .overview-strip {
    padding: 0 10px 8px;
  }

  .search-box {
    margin-inline: 10px;
  }

  .status-tabs {
    margin-inline: 10px;
  }

  .status-tab {
    min-height: 48px;
    font-size: 10px;
  }

  .chat-list {
    padding-inline: 6px;
  }

  .sender-panel {
    align-items: end;
    padding: 0;
  }

  .sender-sheet {
    width: 100%;
    max-height: calc(100dvh - 18px);
    border-radius: 14px 14px 0 0;
  }

  .sender-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 12px;
  }

  .sender-accounts {
    padding-inline: 12px;
  }

  .sender-mode {
    grid-template-columns: 1fr;
  }

  .sender-delay {
    grid-template-columns: 1fr;
  }

  .thread-head {
    max-width: 100%;
    min-width: 0;
    padding: 11px 12px;
  }

  .thread-actions .copy-button:not(:first-child) {
    display: none;
  }

  .thread-actions .copy-button span,
  .thread-actions .open-link span {
    display: none;
  }

  .messages {
    max-width: 100%;
    min-width: 0;
    padding: 14px 10px;
  }

  .message {
    width: min(86%, 620px);
    max-width: calc(100% - 20px);
  }

  .composer-wrap {
    max-width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .quick-actions,
  .composer {
    max-width: calc(100% - 20px);
  }
}
