:root {
  --bg0: #eef3f8;
  --bg1: #f7fafc;
  --ink: #152033;
  --ink-soft: #5a6b82;
  --line: rgba(21, 32, 51, 0.08);
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --shadow: 0 18px 50px rgba(28, 55, 90, 0.08);
  --neg: #d64545;
  --neg-soft: #ffe8e8;
  --neu: #6b7c93;
  --neu-soft: #eef2f6;
  --pos: #1f9d7a;
  --pos-soft: #e6f7f1;
  --accent: #1f6feb;
  --radius: 22px;
  --font: "Figtree", system-ui, sans-serif;
  --display: "Outfit", "Figtree", system-ui, sans-serif;
  --page-gutter: clamp(2rem, 4vw, 3.5rem);
  --page-max: calc(100vw - 2 * var(--page-gutter));
  --board-gap: 1rem;
  --board-visible-cols: 5;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(31, 111, 235, 0.16), transparent 60%),
    radial-gradient(800px 420px at 92% 0%, rgba(31, 157, 122, 0.12), transparent 55%),
    radial-gradient(700px 500px at 70% 100%, rgba(214, 69, 69, 0.08), transparent 50%),
    linear-gradient(180deg, #f4f8fc 0%, #eef3f8 45%, #f7fafc 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(8deg); }
}

.top,
.app-header,
.app-shell-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.app-shell-wrap {
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
}

.header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.75rem var(--page-gutter) 0.65rem;
  box-sizing: border-box;
}

.header-row-main {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 1rem;
  min-height: 58px;
}

.header-row-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  min-height: 2rem;
}

.header-end,
.header-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.header-end {
  justify-self: end;
}

.header-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.header-unhandled-fallback {
  display: none !important;
}

.nav {
  justify-self: center;
}

.header-status .pill {
  padding: 0.32rem 0.62rem;
  font-size: 0.76rem;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  justify-self: end;
}

.brand {
  min-width: 0;
}

.brand-sub {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
}

.poll-pill {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.85rem;
  font-size: 0.84rem;
}

.theme-toggle {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  max-width: var(--page-max);
  margin: 0 auto;
  flex-wrap: wrap;
  min-height: 76px;
}

body.page-chats {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 841px) {
  body.page-chats {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body.page-chats .app-shell-wrap {
    position: static;
    flex-shrink: 0;
    margin: 0.4rem auto 0.35rem;
  }

  body.page-chats .app-stage {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-top: 0.1rem;
  }

  body.page-chats .board {
    flex: 1;
    min-height: 0;
    height: 100%;
    margin: 0 0 0.75rem;
    align-items: stretch;
  }

  body.page-chats .board-full {
    min-height: 0;
  }

  body.page-chats .board-full .chat-col,
  body.page-chats .board .chat-col {
    max-height: 100%;
    min-height: 0;
    height: 100%;
  }
}

body.page-chats .board {
  grid-auto-columns: 420px;
}

body.page-chats .board .chat-col {
  width: 420px;
  min-width: 420px;
  max-width: 420px;
  min-height: 0;
}

@media (min-width: 841px) {
  body.page-chats .board {
    grid-auto-columns: calc(
      (100% - (var(--board-visible-cols) - 1) * var(--board-gap)) / var(--board-visible-cols)
    );
  }

  body.page-chats .board .chat-col {
    width: auto;
    min-width: 0;
    max-width: none;
  }
}

body.page-chats .app-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  box-sizing: border-box;
}

.nav {
  display: inline-flex;
  align-items: center;
  gap: 1.75rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.nav-link {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  padding: 0.62rem 1.4rem;
  border-radius: 13px;
  line-height: 1.15;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 14px rgba(28, 55, 90, 0.06);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(145deg, #1a66e8 0%, #2f8cff 100%);
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.32);
}

.platform-strip-wrap,
.main-nav-wrap {
  position: static;
  z-index: auto;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  background: transparent;
  backdrop-filter: none;
  border-bottom: none;
}

.control-deck-wrap,
.app-shell-wrap {
  max-width: var(--page-max);
  margin: 0.4rem auto 0.35rem;
  padding: 0 var(--page-gutter);
  box-sizing: border-box;
  flex-shrink: 0;
}

.control-deck,
.app-shell {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(28, 55, 90, 0.06);
  overflow: hidden;
}

/* ── Unified app shell ── */
.shell-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem 0.45rem;
}

.brand-shell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-shell .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand-shell h1 {
  font-size: 0.95rem;
  line-height: 1.1;
  margin: 0;
}

.brand-shell .brand-sub {
  font-size: 0.68rem;
  margin: 0.08rem 0 0;
  max-width: none;
  color: var(--ink-soft);
}

.shell-bar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
  min-width: 0;
}

.shell-nav-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.85rem 0.45rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  background: rgba(21, 32, 51, 0.025);
  overflow: visible;
}

.shell-nav-row .main-nav-host {
  flex: 1 1 auto;
  min-width: 0;
}

.shell-nav-row .main-nav-host .main-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  gap: 0.22rem;
  padding: 0.28rem;
  border-radius: 14px;
  background: rgba(21, 32, 51, 0.05);
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  overflow: visible;
}

.shell-nav-row .main-nav-host .nav-link.nav-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.42rem 0.35rem;
  font-size: 0.66rem;
  line-height: 1.15;
  min-height: 1.95rem;
  overflow: visible;
  white-space: nowrap;
}

.shell-nav-row .nav-link.nav-tab.has-badge {
  padding-right: 1.15rem;
  padding-left: 0.28rem;
}

.shell-nav-row .nav-link.has-badge::after {
  top: 0.1rem;
  right: 0.1rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.22rem;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.05rem;
  box-shadow: 0 1px 5px rgba(214, 69, 69, 0.38);
}

.shell-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0;
  flex-shrink: 0;
}

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

.shell-page {
  padding: 0.55rem 0.85rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.shell-page-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.shell-page-text {
  flex: 1 1 12rem;
  min-width: 0;
}

.shell-page-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.shell-page-tools {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shell-page-tools-row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
}

.tool-group {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.tool-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tool-switch {
  display: inline-flex;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.shell-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* legacy aliases */
.platform-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  max-width: none;
  margin: 0;
  padding: 0;
}

.platform-head-text {
  flex: 1 1 12rem;
  min-width: 0;
}

.shell-page-actions .btn.ghost {
  font-size: 0.78rem;
  padding: 0.38rem 0.75rem;
  white-space: nowrap;
}

.control-deck-nav {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.control-deck-nav::-webkit-scrollbar {
  display: none;
}

.control-deck-body {
  padding: 0.7rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-deck .page-head {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.main-nav-host .main-nav {
  width: 100%;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 0.35rem;
  min-width: min-content;
}

.main-nav-host .nav-link.nav-tab {
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.42rem 0.35rem;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: transparent;
  box-shadow: none;
  text-align: center;
  justify-content: center;
  display: inline-flex;
  align-items: center;
}

.shell-nav-row .nav-link.nav-tab:hover {
  background: rgba(255, 255, 255, 0.65);
}

.shell-nav-row .nav-link.nav-tab.active {
  color: #fff;
  box-shadow: 0 4px 14px rgba(28, 55, 90, 0.12);
}

.shell-nav-row .nav-link.nav-max.active {
  background: linear-gradient(145deg, #1a66e8 0%, #2f8cff 100%);
}

.shell-nav-row .nav-link.nav-tg.active {
  background: linear-gradient(145deg, #1b8fd4 0%, #229ed9 100%);
}

.shell-nav-row .nav-link.nav-vk.active {
  background: linear-gradient(145deg, #0066e6 0%, #0077ff 100%);
}

.shell-nav-row .nav-link.nav-topics.active,
.shell-nav-row .nav-link.nav-analytics.active {
  background: linear-gradient(145deg, #1e3340 0%, #2d4a5c 100%);
}

.control-deck .page-head,
.app-shell .page-head {
  max-width: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.nav-link.is-soon {
  opacity: 0.72;
}

.scope-switch {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.22rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.scope-btn,
.period-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.38rem 0.72rem;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.period-switch {
  flex-wrap: nowrap;
  max-width: min(100%, 40rem);
  overflow-x: auto;
}

.period-switch .period-btn {
  font-size: 0.72rem;
  padding: 0.32rem 0.52rem;
}

.scope-btn.active,
.period-btn.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.22);
}

.analytics-page.is-platform .platform-summary,
.analytics-page.is-platform .panel-stat-board {
  display: none;
}

.platform-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0 0 1rem;
}

.platform-card-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.platform-card-link {
  appearance: none;
  border: none;
  background: rgba(31, 111, 235, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.platform-card-feed {
  font-size: 0.78rem;
  font-weight: 650;
  color: #5b4db3;
  text-decoration: none;
  white-space: nowrap;
}

.platform-card-feed:hover {
  text-decoration: underline;
}

@media (max-width: 840px) {
  .platform-summary {
    grid-template-columns: 1fr;
  }
}

.platform-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 1rem 1.05rem 0.9rem;
  background: #fff;
  border: 1px solid rgba(27, 34, 51, 0.06);
  box-shadow: 0 8px 24px rgba(28, 32, 48, 0.05);
  isolation: isolate;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

.platform-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(28, 32, 48, 0.12);
}

.platform-card-glow {
  position: absolute;
  inset: auto -20% -40% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  opacity: 0.35;
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.platform-card:hover .platform-card-glow {
  opacity: 0.55;
  transform: scale(1.12);
}

.platform-card.max { border-top: 3px solid #ff7a59; }
.platform-card.telegram { border-top: 3px solid #2aabee; }
.platform-card.vk { border-top: 3px solid #5b6cff; }
.platform-card.max .platform-card-glow { background: #ff8a68; right: -12%; bottom: -50%; }
.platform-card.telegram .platform-card-glow { background: #5ac8fa; }
.platform-card.vk .platform-card-glow { background: #7b8cff; }
.platform-card.is-active { box-shadow: 0 12px 28px rgba(28, 55, 90, 0.1); }

.platform-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.platform-card-head h3 {
  margin: 0;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.platform-card-link {
  appearance: none;
  border: none;
  background: rgba(31, 111, 235, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}

.platform-card-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
}

.platform-card-stats div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  text-align: center;
}

.platform-card-stats strong {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.platform-card-head,
.platform-card-stats,
.platform-card-tone,
.platform-card-wait {
  position: relative;
  z-index: 1;
}

.platform-card-tone {
  display: flex;
  height: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(27, 34, 51, 0.06);
  margin-top: 0.75rem;
}

.platform-card-tone i {
  display: block;
  height: 100%;
}

.platform-card-tone .neg { background: #e15b5b; }
.platform-card-tone .neu { background: #c5cad6; }
.platform-card-tone .pos { background: #2aa889; }

.platform-card-wait {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--c3-muted, #7a8499);
}

.platform-card-link {
  transition: background 0.18s ease, transform 0.18s ease;
}

.platform-card-link:hover {
  background: rgba(31, 111, 235, 0.16);
  transform: translateY(-1px);
}

.platform-card-stats span {
  font-size: 0.68rem;
  color: var(--ink-soft);
  line-height: 1.15;
}

.platform-card-stats .neg strong { color: var(--neg); }
.platform-card-stats .pos strong { color: var(--pos); }

.bar-platform {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.platform-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  max-width: none;
  margin: 0;
  padding: 0;
}

.platform-head-text {
  flex: 1 1 12rem;
  min-width: 0;
}

.platform-head-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.platform-head-actions .btn.ghost {
  font-size: 0.78rem;
  padding: 0.38rem 0.75rem;
  white-space: nowrap;
}

.platform-empty h3 {
  margin: 0 0 0.5rem;
}

.platform-empty p {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  max-width: 36rem;
}

body[data-platform="max"] .platform-head .page-title,
body[data-platform="max"] .shell-page .page-title {
  color: #1a7a96;
}

body[data-platform="telegram"] .platform-head .page-title,
body[data-platform="telegram"] .shell-page .page-title {
  color: #229ed9;
}

body[data-platform="vk"] .platform-head .page-title,
body[data-platform="vk"] .shell-page .page-title {
  color: #0077ff;
}

.pill.err,
.poll-pill.err {
  color: #b42318;
  background: #ffe8e8;
  border-color: rgba(180, 35, 24, 0.18);
}

.pill.warn-link {
  text-decoration: none;
  color: #c47a12;
  background: #fff4e5;
  border-color: rgba(196, 122, 18, 0.2);
}

.pill.warn-link:hover {
  background: #ffecd2;
}

.page-head {
  max-width: var(--page-max);
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-desc {
  margin: 0.12rem 0 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.35;
  max-width: 38rem;
}

.analytics-page {
  padding-bottom: 2.5rem;
}

.panel-unhandled {
  margin-top: 0.75rem;
}

.panel-unhandled-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.panel-unhandled-head h2 {
  margin-bottom: 0.25rem;
}

.unhandled-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.unhandled-item {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(214, 69, 69, 0.14);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
}

.unhandled-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.unhandled-meta strong {
  color: var(--ink);
}

.unhandled-item p {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
}

body.page-topics {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topics-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter) 2rem;
  box-sizing: border-box;
}

.topics-kpi {
  margin: 0 0 1rem;
  max-width: none;
  padding: 0;
  width: 100%;
}

.topics-board {
  flex: 1;
  margin-top: 0;
  min-height: 0;
}

.topic-col .chat-head h3 {
  font-size: 1.08rem;
}

.topic-col .chat-head p {
  font-size: 0.8rem;
}

.topic-chat {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #3a4d66;
  font-weight: 600;
}

.topic-status {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
}

.topic-status.wait {
  color: #b42318;
  background: rgba(214, 69, 69, 0.1);
  border: 1px solid rgba(214, 69, 69, 0.16);
}

.topic-status.done {
  color: #1f7a55;
  background: rgba(31, 157, 122, 0.1);
  border: 1px solid rgba(31, 157, 122, 0.18);
}

.topic-msg.is-handled {
  opacity: 0.78;
}

.topic-msg-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.topic-msg-row .topic-msg-link {
  display: block;
}

.topic-mod-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 0.15rem;
}

.topic-exclude-btn {
  font-size: 0.76rem;
  padding: 0.32rem 0.7rem;
  min-height: 30px;
  color: #8a4b12;
  background: rgba(255, 244, 229, 0.92);
  border: 1px solid rgba(196, 122, 18, 0.28);
}

.topic-exclude-btn:hover {
  background: #fff4e5;
  border-color: rgba(196, 122, 18, 0.45);
}

.topic-exclude-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.panel-categories-page {
  margin-top: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.topics-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.topics-kpi {
  margin-bottom: 1rem;
  max-width: 720px;
}

.topics-kpi .kpi {
  min-height: 88px;
}

body.page-topics .panel-categories {
  margin-top: 0;
}

.nav-link.has-badge,
.tab.has-badge {
  position: relative;
}

.nav-link.has-badge::after,
.tab.has-badge::after {
  content: attr(data-badge);
  position: absolute;
  top: -0.42rem;
  right: -0.38rem;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #d64545;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.4rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(214, 69, 69, 0.35);
  z-index: 2;
  pointer-events: none;
}

.tab.has-badge::after {
  top: 4px;
  right: calc(50% - 1.35rem);
}

.panel-categories {
  margin-top: 0.75rem;
  background:
    radial-gradient(1200px 320px at 0% 0%, rgba(31, 111, 235, 0.06), transparent 55%),
    radial-gradient(900px 280px at 100% 0%, rgba(214, 69, 69, 0.05), transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.92));
  border-color: rgba(31, 111, 235, 0.12);
}

.panel-categories-head {
  margin-bottom: 1rem;
}

.panel-categories-head h2 {
  margin-bottom: 0.25rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.category-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  padding: 2.5rem 1.5rem;
  border-radius: 18px;
  border: 1px dashed rgba(31, 111, 235, 0.18);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  text-align: center;
}

.category-empty-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1f9d7a;
  background: rgba(31, 157, 122, 0.12);
  border: 1px solid rgba(31, 157, 122, 0.22);
}

.category-empty p {
  margin: 0;
  max-width: 28rem;
  font-size: 0.92rem;
}

.category-block {
  --cat-accent: #1f6feb;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid color-mix(in srgb, var(--cat-accent) 18%, var(--line));
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 14px 34px color-mix(in srgb, var(--cat-accent) 8%, transparent);
  display: flex;
  flex-direction: column;
  min-height: 240px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.category-block:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95) inset,
    0 18px 40px color-mix(in srgb, var(--cat-accent) 12%, transparent);
}

.category-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.95rem 1rem 0.9rem;
  border-bottom: 1px solid color-mix(in srgb, var(--cat-accent) 12%, var(--line));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--cat-accent) 10%, #fff) 0%,
    rgba(255, 255, 255, 0.96) 58%
  );
}

.category-head-main {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
}

.category-badge {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--cat-accent);
  background: color-mix(in srgb, var(--cat-accent) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--cat-accent) 24%, transparent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--cat-accent) 10%, transparent);
}

.category-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}

.category-hint {
  margin: 0.18rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.category-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.category-alert {
  font-size: 0.68rem;
  font-weight: 700;
  color: #b42318;
  background: rgba(214, 69, 69, 0.1);
  border: 1px solid rgba(214, 69, 69, 0.18);
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.category-count {
  flex-shrink: 0;
  min-width: 1.8rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--cat-accent);
  background: color-mix(in srgb, var(--cat-accent) 10%, #fff);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--cat-accent) 18%, transparent);
}

.category-msgs {
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(248, 251, 255, 0.55));
}

.category-msg {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem 0.75rem 0.95rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.category-msg::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--cat-accent);
  opacity: 0.85;
}

.category-msg.pending {
  border-color: color-mix(in srgb, var(--cat-accent) 22%, var(--line));
  background: linear-gradient(90deg, color-mix(in srgb, var(--cat-accent) 5%, #fff), #fff 18%);
}

.category-msg.handled {
  opacity: 0.72;
}

.category-msg.handled::before {
  opacity: 0.35;
}

.category-msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  max-width: 100%;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.category-msg-meta strong {
  flex: 1 1 6rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.76rem;
}

.category-chat {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #3a4d66;
  font-weight: 600;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  background: #eef2f8;
}

.category-status {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
}

.category-status.wait {
  color: #b42318;
  background: rgba(214, 69, 69, 0.1);
  border: 1px solid rgba(214, 69, 69, 0.16);
}

.category-status.done {
  color: #1f7a55;
  background: rgba(31, 157, 122, 0.1);
  border: 1px solid rgba(31, 157, 122, 0.18);
}

.category-msg p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-wrap.priority-msg .bubble-meta {
  flex-wrap: wrap;
}

.bubble-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
  max-width: 100%;
  min-width: 0;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.bubble-meta .author {
  flex: 1 1 6rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: #3a4d66;
}

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

.bubble-meta .sentiment-tag,
.bubble-meta .msg-type,
.bubble-meta .priority-tag,
.bubble-meta .topic-status,
.bubble-meta .topic-chat {
  flex: 0 1 auto;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff8e8, #ffefd0);
  color: #9a5b00;
  border: 1px solid rgba(196, 122, 18, 0.28);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bubble.priority {
  border-color: rgba(196, 122, 18, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 196, 84, 0.35),
    0 8px 22px rgba(196, 122, 18, 0.12);
  background: linear-gradient(180deg, #fff 0%, #fffaf0 100%);
}

.bubble-wrap.priority-msg .bubble.negative.priority {
  background: linear-gradient(180deg, #fff 0%, #fff6f0 100%);
  border-color: rgba(214, 69, 69, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 196, 84, 0.3),
    0 8px 22px rgba(214, 69, 69, 0.1);
}

.board-full {
  min-height: 0;
}

@media (max-width: 840px) {
  .board-full {
    min-height: calc(100vh - 180px);
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, #1f6feb 0%, #3aa0ff 55%, #1f9d7a 100%);
  box-shadow: 0 10px 24px rgba(31, 111, 235, 0.28);
  position: relative;
  animation: pulse-mark 3.2s ease-in-out infinite;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 12px 10px 14px 14px;
  border-radius: 10px 10px 10px 3px;
  background: rgba(255, 255, 255, 0.92);
}

@keyframes pulse-mark {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-sub {
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.pill.muted {
  color: var(--ink-soft);
  font-weight: 500;
}

.pill.live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pos);
  box-shadow: 0 0 0 3px rgba(31, 157, 122, 0.2);
  animation: blink 1.6s ease infinite;
}

.addr-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.addr-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 8px;
  background: #e8f0fe;
  color: #1a56b0;
  font-size: 0.72rem;
  font-weight: 650;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes blink {
  50% { opacity: 0.45; }
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.55rem 0.95rem;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn.is-loading,
.tab.is-loading {
  opacity: 0.65;
  pointer-events: none;
  position: relative;
}

.btn.is-loading::after,
.tab.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.4em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -0.05em;
  animation: spin 0.7s linear infinite;
}

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


.btn.ghost {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.ghost:hover {
  background: #fff;
  box-shadow: var(--shadow);
}

.btn.sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 10px;
}

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

.btn.primary:hover {
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.28);
}

.btn.soft-neg {
  background: #ffe8e8;
  color: var(--neg);
}

.btn.soft-pos {
  background: var(--pos-soft);
  color: var(--pos);
}

.analytics {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0.5rem var(--page-gutter) 0;
  box-sizing: border-box;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.analytics-page .kpi-grid,
.analytics .kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.analytics-page .kpi-grid .kpi,
.analytics .kpi-grid .kpi {
  min-height: 5.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kpi {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow);
  animation: rise 0.5s ease both;
}

.kpi:nth-child(2) { animation-delay: 0.04s; }
.kpi:nth-child(3) { animation-delay: 0.08s; }
.kpi:nth-child(4) { animation-delay: 0.12s; }
.kpi:nth-child(5) { animation-delay: 0.16s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.kpi-label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.kpi-value {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.kpi-hint {
  margin-left: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.kpi.neg .kpi-value { color: var(--neg); }
.kpi.pos .kpi-value { color: var(--pos); }
.kpi.neu .kpi-value { color: var(--neu); }
.kpi.warn .kpi-value { color: #c47a12; }

.analytics-panels {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 0.75rem;
  margin-top: 0;
}

.analytics-panels.tops {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.panel-lead {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.top-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.55rem 0.6rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(21, 32, 51, 0.05);
  transition: transform 0.15s ease, background 0.15s ease;
}

.top-row:hover {
  background: #fff;
  transform: translateY(-1px);
}

.top-rank {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.78rem;
  background: #eef3f8;
  color: var(--ink-soft);
}

.top-row:nth-child(1) .top-rank {
  background: #ffe5e5;
  color: var(--neg);
}

.top-row:nth-child(2) .top-rank {
  background: #fff0e4;
  color: #c47a12;
}

.top-row:nth-child(3) .top-rank {
  background: #e8eef8;
  color: var(--accent);
}

.top-main {
  min-width: 0;
}

.top-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-sub {
  margin-top: 0.15rem;
  font-size: 0.74rem;
  color: var(--ink-soft);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.top-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.top-stat strong {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--neg);
  letter-spacing: -0.02em;
}

.top-stat span {
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.top-meter {
  grid-column: 2 / -1;
  height: 5px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
  margin-top: 0.15rem;
}

.top-meter > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #e85d4c, #d64545);
  border-radius: inherit;
}

.panel-stat-board {
  margin-top: 0.15rem;
}

.panel-stat-board-head {
  margin-bottom: 0.35rem;
}

.analytics-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(272px, 82vw);
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0.15rem 0.85rem;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.15rem;
  -webkit-overflow-scrolling: touch;
}

.analytics-board-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.stat-card {
  --stat-accent: var(--accent);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 100%;
  padding: 0.85rem 0.9rem 0.9rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--stat-accent);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(28, 55, 90, 0.07);
}

.stat-card-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.stat-card-avatar {
  width: 40px;
  height: 40px;
  font-size: 0.74rem;
  flex-shrink: 0;
}

.stat-card-head-text {
  min-width: 0;
  flex: 1;
}

.stat-card-head-text h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.stat-card-platform {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.stat-card-metrics div {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
  text-align: center;
  padding: 0.35rem 0.2rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
}

.stat-card-metrics strong {
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-card-metrics span {
  font-size: 0.62rem;
  color: var(--ink-soft);
  line-height: 1.15;
}

.stat-card-metrics .neg strong { color: var(--neg); }
.stat-card-metrics .pos strong { color: var(--pos); }

.stat-card-tone {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stat-card-bar {
  height: 8px;
}

.stat-card-share {
  font-size: 0.74rem;
  color: var(--ink-soft);
  font-weight: 650;
}

.stat-card-link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.stat-card-link:hover {
  background: #fff;
  border-color: color-mix(in srgb, var(--stat-accent) 35%, var(--line));
  transform: translateY(-1px);
}

.pages-tables {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.pages-table-block {
  min-width: 0;
}

.pages-table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.pages-table-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.pages-table-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.pages-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.pages-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.pages-table th,
.pages-table td {
  padding: 0.72rem 0.85rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.pages-table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.pages-table tbody tr:last-child td {
  border-bottom: 0;
}

.pages-table tbody tr:hover td {
  background: rgba(40, 169, 197, 0.06);
}

.pages-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.pages-table .num.up { color: #168a5c; }
.pages-table .num.down { color: #c53c3c; }
.pages-table .num.flat,
.pages-table .num.muted { color: var(--ink-soft); font-weight: 600; }

.pages-td-page {
  min-width: 180px;
  max-width: 280px;
}

.pages-page-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.pages-page-link:hover .pages-page-name {
  color: var(--accent);
}

.pages-page-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pages-page-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pages-td-tone {
  min-width: 180px;
}

.pages-tone {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 160px;
}

.pages-tone-bar {
  height: 8px;
}

.pages-tone-meta {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-soft);
  white-space: nowrap;
}

.pages-tone-meta .neg { color: var(--neg); }
.pages-tone-meta .pos { color: var(--pos); }

.pages-td-empty {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 1.1rem 0.85rem;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rank-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.rank-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.rank-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 52px;
  gap: 0.6rem;
  align-items: center;
}

.bar-label {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
  display: flex;
}

.bar-seg {
  height: 100%;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-seg.neg { background: var(--neg); }
.bar-seg.neu { background: #a8b4c4; }
.bar-seg.pos { background: var(--pos); }

.bar-pct {
  font-size: 0.78rem;
  color: var(--neg);
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  max-width: var(--page-max);
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.control-deck .toolbar,
.app-shell .toolbar {
  max-width: none;
  flex: 1 1 280px;
  min-width: 0;
}

.control-deck .filters,
.app-shell .filters {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid color-mix(in srgb, var(--line) 90%, transparent);
  border-radius: 12px;
  padding: 0.4rem 0.55rem;
  gap: 0.45rem;
}

@media (min-width: 841px) {
  .app-shell {
    --shell-bar-h: 3.15rem;
    --shell-nav-h: 3.35rem;
    --shell-page-h: 4.9rem;
  }

  .shell-bar {
    min-height: var(--shell-bar-h);
    box-sizing: border-box;
    align-items: center;
  }

  .shell-nav-row {
    min-height: var(--shell-nav-h);
    box-sizing: border-box;
    align-items: center;
  }

  .shell-nav-row .shell-meta {
    flex: 0 0 auto;
    min-width: 10.5rem;
    justify-content: flex-end;
  }

  .shell-nav-row .shell-meta[hidden] {
    display: flex !important;
    visibility: hidden;
    pointer-events: none;
  }

  body:not(.page-analytics) #registryPill[hidden] {
    display: block !important;
    visibility: hidden;
    pointer-events: none;
  }

  .shell-page,
  .shell-page.shell-page-split {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.85rem 1.15rem;
    flex-wrap: nowrap;
    min-height: var(--shell-page-h);
    box-sizing: border-box;
  }

  .shell-page-split .shell-page-head,
  .shell-page .shell-page-head {
    flex: 0 0 14rem;
    width: 14rem;
    max-width: 14rem;
    flex-direction: column;
    align-items: flex-start;
    align-self: center;
    gap: 0.2rem;
  }

  .shell-page-split .page-desc,
  .shell-page .page-desc {
    display: block;
  }

  .shell-page-split .shell-page-text {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }

  .shell-page-split .shell-page-actions {
    width: 100%;
    flex-shrink: 0;
  }

  .shell-page-split .shell-page-tools,
  .shell-page .shell-page-tools {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.85rem;
    align-self: center;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
  }

  .shell-page-split .shell-page-tools .filters {
    width: 100%;
    margin: 0;
    flex-wrap: nowrap;
  }

  .shell-page-split .field {
    min-width: 82px;
    flex: 0 1 auto;
  }

  .shell-page-split .field.grow {
    flex: 1 1 100px;
    min-width: 88px;
  }

  .shell-page-split .shell-page-tools-row {
    flex: 1;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0.65rem 1rem;
    width: 100%;
  }

  .shell-page-split .tool-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.28rem;
  }

  .shell-page-split .tool-label {
    margin: 0;
    white-space: nowrap;
  }
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.85rem;
  backdrop-filter: blur(10px);
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.field.grow {
  flex: 1;
  min-width: 180px;
}

.field span,
.toggle span {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field select,
.field input {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  outline: none;
}

.field select:focus,
.field input:focus {
  border-color: rgba(31, 111, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  margin-left: auto;
}

.toggle span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

.board {
  width: 100%;
  max-width: none;
  margin: 0.35rem 0 2rem;
  padding: 0 0 1.25rem;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 420px;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 52vh;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.75rem;
  align-content: start;
  flex: 1;
}

.board:not(.is-empty)::after {
  content: '';
  width: 0.75rem;
  flex-shrink: 0;
}

.board.is-empty {
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.board-empty {
  flex: 1;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 1600px;
  min-height: 280px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.board.board-stable .chat-col {
  animation: none;
}

.board .chat-col {
  width: 420px;
  min-width: 420px;
  max-width: 420px;
}

.board .chat-head {
  padding: 1.05rem 1.1rem;
}

.board .chat-head h3 {
  font-size: 1.08rem;
}

.board .chat-head p {
  font-size: 0.8rem;
}

.board .chat-avatar {
  width: 42px;
  height: 42px;
  font-size: 0.92rem;
}

.board .chat-messages {
  padding: 1.1rem 1rem 1.2rem;
  gap: 0.85rem;
}

.board .bubble-text {
  font-size: 0.96rem;
  line-height: 1.48;
}

.board .bubble-meta {
  font-size: 0.76rem;
}

.board .bubble {
  padding: 0.78rem 0.9rem 0.82rem;
}

.board-full .chat-col {
  max-height: calc(100vh - 200px);
  min-height: 580px;
}

@media (min-width: 841px) {
  body.page-chats .board-full .chat-col {
    max-height: 100%;
    min-height: 0;
    height: 100%;
  }
}

.chat-col {
  scroll-snap-align: start;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: calc(100vh - 280px);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

@media (min-width: 841px) {
  body.page-chats .chat-col {
    min-height: 0;
    max-height: 100%;
    height: 100%;
  }
}

.chat-head-text {
  min-width: 0;
}

.chat-head h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
}

.chat-head p {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding: 1rem 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background:
    linear-gradient(180deg, rgba(238, 243, 248, 0.35), transparent 40%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 11px,
      rgba(21, 32, 51, 0.015) 11px,
      rgba(21, 32, 51, 0.015) 12px
    );
}

.chat-empty-hint {
  margin: 0.35rem 0;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.4;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.85rem;
}

.bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.sentiment-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sentiment-tag.negative {
  background: #ffe5e5;
  color: var(--neg);
}

.sentiment-tag.neutral {
  background: var(--neu-soft);
  color: var(--neu);
}

.sentiment-tag.positive {
  background: var(--pos-soft);
  color: var(--pos);
}

.bubble {
  position: relative;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  padding: 0.7rem 0.85rem 0.75rem;
  box-shadow: 0 6px 18px rgba(28, 55, 90, 0.06);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.bubble.negative {
  background: linear-gradient(180deg, #fff 0%, #fff6f6 100%);
  border-color: rgba(214, 69, 69, 0.22);
}

.bubble.positive {
  background: linear-gradient(180deg, #fff 0%, #f3fbf8 100%);
  border-color: rgba(31, 157, 122, 0.2);
}

.bubble.handled {
  opacity: 0.62;
}

.bubble-text {
  margin: 0;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-post-ref {
  display: block;
  margin: 0 0 0.45rem;
  padding: 0.35rem 0.55rem;
  border-left: 3px solid rgba(40, 169, 197, 0.55);
  border-radius: 0 8px 8px 0;
  background: rgba(40, 169, 197, 0.08);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
  text-decoration: none;
}

.bubble-post-ref:hover {
  color: var(--ink);
  background: rgba(40, 169, 197, 0.14);
}

[data-theme="dark"] .bubble-post-ref {
  background: rgba(40, 169, 197, 0.12);
  border-left-color: rgba(40, 169, 197, 0.7);
}

.bubble-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.msg-type {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #e8f0fe;
  color: #1a56b0;
  font-size: 0.68rem;
  font-weight: 700;
}

.msg-type.question, .msg-type.complaint { background: #fff0e4; color: #b76512; }
.msg-type.thanks, .msg-type.gratitude { background: var(--pos-soft); color: var(--pos); }

.label-actions { display: inline-flex; gap: 0.2rem; margin-left: auto; }
.label-actions button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  min-width: 30px; min-height: 30px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700;
}

.queue-page { max-width: 840px; margin: 0 auto; padding: 0.75rem 1rem 2rem; }
.queue-head { margin: 1rem 0 0.75rem; }
.queue-list { display: grid; gap: 0.75rem; }
.queue-swipe { position: relative; overflow: hidden; border-radius: 18px; }
.swipe-hint { position: absolute; inset: 0; display: flex; justify-content: flex-end; align-items: center; padding-right: 1.25rem; background: var(--pos); color: #fff; font-weight: 700; }
.queue-card { position: relative; background: var(--card); border: 1px solid rgba(214,69,69,.2); border-radius: 18px; padding: 1rem; box-shadow: var(--shadow); touch-action: pan-y; }
.queue-card p { margin: .6rem 0; white-space: pre-wrap; word-break: break-word; }
.queue-meta, .queue-tags, .queue-actions, .template-list { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.queue-meta { font-size: .78rem; color: var(--ink-soft); }
.queue-meta strong { color: var(--ink); }
.queue-meta time { margin-left: auto; }
.queue-tags { gap: .3rem; }
.queue-actions { margin-top: .8rem; }
.queue-actions .btn { min-height: 44px; }
.template-list { margin-bottom: .75rem; }
.template-chip { border: 1px solid rgba(31,111,235,.2); background: #eef4ff; color: var(--accent); border-radius: 999px; min-height: 44px; padding: .45rem .8rem; font: inherit; font-weight: 650; cursor: pointer; }
.incidents { padding: .4rem .85rem; }
.incident-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 0; background: transparent; padding: .45rem 0; font: inherit; font-weight: 700; cursor: pointer; }
.incident-card { margin: .5rem 0; padding: .65rem .75rem; border-radius: 12px; background: #fff7e9; border: 1px solid rgba(196,122,18,.16); }
.incident-card p { margin: .2rem 0; color: var(--ink-soft); font-size: .85rem; }
.incident-card span { font-size: .75rem; color: #b76512; font-weight: 700; }
.queue-empty { text-align: center; color: var(--ink-soft); }

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: #152033;
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  z-index: 50;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .analytics-page .kpi-grid,
  .analytics .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analytics-panels,
  .analytics-panels.tops {
    grid-template-columns: 1fr;
  }
  .bar-row {
    grid-template-columns: 110px 1fr 48px;
  }
}

/* ——— Mobile / PWA app shell ——— */
.mobile-only {
  display: none !important;
}

.app-stage {
  width: 100%;
  max-width: none;
  margin: 0;
}

.chat-list {
  display: none;
}

.topic-list {
  display: none;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
}

.icon-btn.warn {
  background: #fff4e5;
  color: #c47a12;
  border-color: rgba(196, 122, 18, 0.25);
  min-width: 42px;
  padding: 0 0.55rem;
  width: auto;
}

.tab-bar {
  display: none;
}

.thread-placeholder,
.chat-list-empty {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--ink-soft);
  text-align: center;
  padding: 2rem;
}

.back-btn {
  appearance: none;
  border: none;
  background: rgba(21, 32, 51, 0.06);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--ink);
}

@media (max-width: 840px) {
  .mobile-only:not(.c3-mobile-bar) {
    display: revert !important;
  }

  .desktop-only,
  .nav.desktop-only,
  .top-meta.desktop-only,
  .header-status.desktop-only {
    display: none !important;
  }

  .header-inner {
    padding: 0.55rem 0.9rem 0.5rem;
  }

  .header-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 44px;
  }

  .header-row-sub {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .header-context {
    width: 100%;
  }

  .brand-sub {
    max-width: 10rem;
    font-size: 0.72rem;
  }

  html {
    height: 100%;
  }

  body {
    min-height: 100%;
    min-height: 100dvh;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.page-chats,
  body.page-topics {
    overscroll-behavior-y: auto;
  }

  body.page-analytics,
  body.page-channels {
    overflow-x: hidden;
  }

  body.page-topics {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.page-topics .page-head {
    flex-shrink: 0;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  body.page-topics .topics-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
  }

  body.page-topics .topics-kpi,
  body.page-topics .topic-chips {
    flex-shrink: 0;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  body.page-topics:not(.thread-mode) .topics-board {
    display: none !important;
  }

  body.page-topics.list-mode .topics-board {
    display: none !important;
  }

  body.page-topics:not(.thread-mode) .topic-list {
    display: flex !important;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  body.page-topics.thread-mode .topic-list {
    display: none !important;
  }

  body.page-topics.thread-mode .topics-board {
    flex: 1;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    grid-auto-flow: unset;
    grid-auto-columns: unset;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }

  body.page-topics.thread-mode .topics-board .topic-col {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: 1;
    min-height: 0;
    max-height: none;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    animation: none;
  }

  .topics-kpi {
    padding: 0;
    max-width: none;
  }

  body.page-chats .app-stage {
    max-width: none;
    padding: 0;
  }

  .topics-board {
    margin: 0;
    padding: 0;
  }

  body.page-chats {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    padding-bottom: 0;
  }

  body.page-chats.list-mode .app-stage {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  body.page-chats.list-mode .chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .atmosphere {
    animation: none;
  }

  .app-header.top,
  .app-header,
  .app-shell-wrap {
    position: sticky;
    top: 0;
    z-index: 30;
    max-width: none;
    margin: 0;
    background: transparent;
    backdrop-filter: none;
    border-bottom: none;
  }

  .app-shell {
    border-radius: 16px;
  }

  .app-header .header-inner {
    padding:
      calc(0.55rem + env(safe-area-inset-top, 0px))
      0.9rem
      0.5rem;
  }

  .app-header .nav {
    display: none;
  }

  .app-header .theme-toggle.desktop-only {
    display: none !important;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.55rem;
  }

  .brand-text {
    min-width: 0;
    overflow: hidden;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    flex-shrink: 0;
  }

  .brand-mark::after {
    content: none;
    display: none;
  }

  .brand h1 {
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-sub {
    display: none;
  }

  .shell-bar {
    padding: calc(0.45rem + env(safe-area-inset-top, 0px)) 0.65rem 0.4rem;
  }

  .shell-nav-row {
    display: none;
  }

  .shell-page {
    padding: 0.55rem 0.65rem 0.65rem;
    flex-direction: column;
    min-height: 0;
    align-items: stretch;
  }

  .shell-page .shell-page-head {
    flex: none;
    width: auto;
    max-width: none;
  }

  .shell-page-tools:empty,
  .shell-page-tools[aria-hidden="true"] {
    display: none !important;
    min-height: 0;
  }

  .shell-page-tools-row {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-switch {
    width: 100%;
    justify-content: stretch;
  }

  .tool-switch .scope-btn,
  .tool-switch .period-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .shell-actions .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    flex-shrink: 0;
  }

  .header-actions .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    flex-shrink: 0;
  }

  .filter-sheet.toolbar {
    max-width: none;
    margin: 0;
    padding: 0 0.9rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    flex-shrink: 0;
    transition: max-height 0.28s ease, opacity 0.2s ease, padding 0.2s ease;
    border: none;
    background: transparent;
  }

  body.filters-open .filter-sheet.toolbar {
    max-height: 320px;
    opacity: 1;
    padding: 0.55rem 0.9rem 0.75rem;
    background: rgba(255, 255, 255, 0.72);
    border-bottom: 1px solid var(--line);
  }

  .filter-sheet .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .filter-sheet .field,
  .filter-sheet .field.grow {
    min-width: 0;
    width: 100%;
  }

  .filter-sheet select,
  .filter-sheet input {
    font-size: 16px; /* без автозума iOS */
    min-height: 44px;
  }

  .app-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
  }

  .chat-list,
  .topic-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding: 0.35rem 0.65rem 0.75rem;
    gap: 0.35rem;
  }

  body.page-topics.list-mode .topic-list {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .topic-list-item {
    width: 100%;
  }

  body.thread-mode .chat-list {
    display: none;
  }

  body.list-mode .board {
    display: none;
  }

  .chat-list-item {
    appearance: none;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    border-radius: 16px;
    padding: 0.75rem 0.8rem;
    display: flex;
    gap: 0.75rem;
    text-align: left;
    cursor: pointer;
    width: 100%;
    font: inherit;
    color: inherit;
    transition: background 0.15s ease, transform 0.12s ease;
  }

  .chat-list-item:active {
    transform: scale(0.985);
  }

  .chat-list-item.active {
    border-color: rgba(31, 111, 235, 0.35);
    background: #eef4ff;
  }

  .chat-list-body {
    flex: 1;
    min-width: 0;
  }

  .chat-list-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: baseline;
  }

  .chat-list-top strong {
    font-family: var(--display);
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-list-top time {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--ink-soft);
  }

  .chat-list-preview {
    margin: 0.2rem 0 0.35rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--ink-soft);
  }

  .chip {
    display: inline-flex;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-weight: 700;
  }

  .chip.neg {
    background: var(--neg-soft);
    color: var(--neg);
  }

  .chip.warn {
    background: #fff4e5;
    color: #c47a12;
  }

  .board {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 0;
    display: flex;
    grid-auto-flow: unset;
    grid-auto-columns: unset;
    overflow: hidden;
    max-width: none;
  }

  .board .chat-col,
  .board-full .chat-col,
  .chat-col.thread-open {
    width: 100%;
    max-width: none;
    min-height: 0;
    max-height: none;
    height: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    animation: none;
  }

  .chat-head {
    padding: 0.7rem 0.75rem;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .chat-head-text {
    min-width: 0;
  }

  .chat-head-text h3 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-messages {
    padding: 0.85rem 0.75rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }

  .bubble-wrap {
    max-width: 100%;
  }

  .bubble-actions .btn {
    min-height: 40px;
    padding: 0.55rem 0.85rem;
  }

  .tab-bar {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 0.45rem 0.35rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    gap: 0.15rem;
  }

  .tab {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    padding: 0.42rem 0.3rem;
    border-radius: 14px;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    min-height: 54px;
    cursor: pointer;
    position: relative;
  }

  .tab svg {
    width: 24px;
    height: 24px;
  }

  .tab.active {
    color: var(--accent);
    background: rgba(31, 111, 235, 0.1);
    box-shadow: inset 0 0 0 1px rgba(31, 111, 235, 0.12);
  }

  .tab:disabled {
    opacity: 0.5;
  }

  .toast {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 2rem);
  }

  /* Unified shell mobile */
  .app-shell-wrap,
  .control-deck-wrap {
    margin: 0.35rem auto 0.45rem;
    padding: 0 0.65rem;
  }

  .platform-head-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Analytics mobile */
  .page-head {
    padding: 0;
    margin: 0;
  }

  .page-title {
    font-size: 1.2rem;
  }

  .page-desc {
    font-size: 0.82rem;
  }

  .analytics-page,
  .analytics {
    padding: 0.5rem 0.75rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
  }

  .analytics-board {
    grid-auto-columns: min(260px, 88vw);
    gap: 0.65rem;
  }

  .pages-table {
    min-width: 560px;
    font-size: 0.82rem;
  }

  .pages-table th,
  .pages-table td {
    padding: 0.62rem 0.7rem;
  }

  .pages-table-head {
    flex-wrap: wrap;
  }

  .stat-card-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-panels,
  .analytics-panels.tops {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .panel,
  .panel-wide {
    min-width: 0;
    overflow: visible;
  }

  .bars {
    min-width: 0;
  }

  .bar-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label pct"
      "track track";
    gap: 0.3rem 0.5rem;
    align-items: center;
  }

  .bar-label {
    grid-area: label;
    white-space: normal;
    word-break: break-word;
  }

  .bar-track {
    grid-area: track;
    width: 100%;
  }

  .bar-pct {
    grid-area: pct;
    text-align: right;
    white-space: nowrap;
  }

  .trend-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.45rem;
  }

  .trend-main {
    min-width: 0;
  }

  .trend-main strong {
    word-break: break-word;
  }

  .top-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
  }

  .ch-overview,
  .ch-overview-charts,
  .ch-charts,
  .ch-charts-compact,
  .ch-grid {
    grid-template-columns: 1fr !important;
  }

  .ch-kpi-grid,
  .ch-kpi-grid-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ch-chart,
  .ch-overview-card,
  .ch-charts-block {
    min-width: 0;
    width: 100%;
    overflow: visible;
  }

  .ch-overview-charts,
  .ch-charts,
  .ch-charts-compact {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  .ch-donut {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.65rem;
  }

  .ch-donut-legend {
    width: 100%;
  }

  .ch-chart-svg,
  .ch-donut-svg {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .topics-kpi {
    max-width: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .topics-kpi .kpi {
    min-height: 76px;
    padding: 0.65rem 0.7rem;
  }

  .topics-kpi .kpi-label,
  .topics-kpi .kpi-hint {
    font-size: 0.68rem;
  }

  .topics-kpi .kpi-value {
    font-size: 1.35rem;
  }

  body.page-topics {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
  }

  .analytics-page .kpi-grid,
  .analytics .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi.warn {
    grid-column: 1 / -1;
  }

  .panel {
    border-radius: 16px;
    padding: 0.85rem;
  }

  .unhandled-list {
    grid-template-columns: 1fr;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .category-msgs {
    max-height: 280px;
  }

  .panel-unhandled-head {
    flex-direction: column;
    align-items: stretch;
  }
}

/* standalone PWA: чуть плотнее статус-бар */
@media (display-mode: standalone) {
  body.is-mobile .app-header .header-inner {
    padding-top: calc(0.45rem + env(safe-area-inset-top, 0px));
  }
}

@media (max-width: 720px) {
  .top {
    flex-direction: row;
    align-items: center;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ——— Context pills, chips, period, trends, theme ——— */

.ctx-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.ctx-pill.warn {
  color: #b42318;
  background: rgba(214, 69, 69, 0.1);
  border-color: rgba(214, 69, 69, 0.2);
}

.ctx-pill.hot {
  color: #c47a12;
  background: #fff4e5;
  border-color: rgba(196, 122, 18, 0.22);
}

.ctx-pill.ok {
  color: #1f7a55;
  background: rgba(31, 157, 122, 0.1);
  border-color: rgba(31, 157, 122, 0.2);
}

.ctx-pill.muted {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
}

.theme-toggle {
  flex-shrink: 0;
}

.topic-chips {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0 0 0.85rem;
  margin: 0 0 0.25rem;
  max-width: none;
  width: 100%;
  scrollbar-width: none;
}

.topic-chips::-webkit-scrollbar {
  display: none;
}

.chip-filter {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.chip-filter.active {
  color: #fff;
  background: var(--chip-accent, var(--accent));
  border-color: transparent;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--chip-accent, var(--accent)) 28%, transparent);
}

.chip-filter.empty:not(.active) {
  opacity: 0.45;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.trend-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.trend-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.trend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.trend-main strong {
  display: block;
  font-size: 0.9rem;
}

.trend-sub {
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.trend-delta {
  font-weight: 800;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.trend-row.up .trend-delta {
  color: #d64545;
}

.trend-row.down .trend-delta {
  color: #1f9d7a;
}

.trend-row.flat .trend-delta {
  color: var(--ink-soft);
}

.topic-msg-link {
  text-decoration: none;
  color: inherit;
  display: block;
  border-radius: 14px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.topic-msg-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.msg-highlight {
  outline: 2px solid rgba(31, 111, 235, 0.55);
  outline-offset: 3px;
  border-radius: 14px;
  animation: msg-pulse 1.2s ease-in-out 2;
}

@keyframes msg-pulse {
  0%, 100% { outline-color: rgba(31, 111, 235, 0.55); }
  50% { outline-color: rgba(255, 196, 84, 0.9); }
}

[data-theme="dark"] {
  --bg0: #0c1016;
  --bg1: #121820;
  --ink: #f2f6fc;
  --ink-soft: #b9c7db;
  --line: rgba(255, 255, 255, 0.12);
  --card: rgba(30, 38, 50, 0.94);
  --card-solid: #263241;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
  --neg: #ff8a8a;
  --neg-soft: rgba(255, 120, 120, 0.18);
  --neu: #a8b8ce;
  --neu-soft: rgba(168, 184, 206, 0.16);
  --pos: #66d4ae;
  --pos-soft: rgba(102, 212, 174, 0.16);
  --accent: #72b6ff;
}

[data-theme="dark"] body {
  background: var(--bg0);
  color: var(--ink);
}

[data-theme="dark"] .atmosphere {
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(72, 140, 255, 0.14), transparent 60%),
    radial-gradient(800px 420px at 92% 0%, rgba(80, 200, 160, 0.08), transparent 55%),
    linear-gradient(180deg, #10161f 0%, #0c1016 45%, #121820 100%);
  animation: none;
}

[data-theme="dark"] .app-header,
[data-theme="dark"] .top,
[data-theme="dark"] .tab-bar {
  background: rgba(12, 16, 22, 0.94);
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .nav {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

[data-theme="dark"] .nav-link {
  color: #c5d2e4;
}

[data-theme="dark"] .nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

[data-theme="dark"] .nav-link.active {
  color: #fff;
  background: linear-gradient(145deg, #2a7ae8 0%, #4a9dff 100%);
  box-shadow: 0 10px 22px rgba(42, 122, 232, 0.35);
}

[data-theme="dark"] .pill,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .btn.ghost {
  background: #243040;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

[data-theme="dark"] .pill.muted {
  color: var(--ink-soft);
}

[data-theme="dark"] .pill.live::before {
  box-shadow: 0 0 0 3px rgba(102, 212, 174, 0.28);
}

[data-theme="dark"] .pages-table-wrap,
[data-theme="dark"] .pages-table th {
  background: #243040;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .pages-table tbody tr:hover td {
  background: rgba(114, 182, 255, 0.08);
}

[data-theme="dark"] .field select:focus,
[data-theme="dark"] .field input:focus {
  border-color: rgba(114, 182, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(114, 182, 255, 0.16);
}

[data-theme="dark"] .chat-col,
[data-theme="dark"] .topic-exclude-btn {
  color: #ffd4a8;
  background: rgba(255, 160, 80, 0.14);
  border-color: rgba(255, 160, 80, 0.32);
}

[data-theme="dark"] .topic-exclude-btn:hover {
  background: rgba(255, 160, 80, 0.24);
}

[data-theme="dark"] .topic-col {
  background: #1a222d;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
}

[data-theme="dark"] .chat-head {
  background: #2a3544;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .chat-head h3 {
  color: var(--ink);
}

[data-theme="dark"] .chat-head p {
  color: var(--ink-soft);
}

[data-theme="dark"] .chat-messages {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 36%),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 11px,
      rgba(255, 255, 255, 0.018) 11px,
      rgba(255, 255, 255, 0.018) 12px
    );
}

[data-theme="dark"] .bubble {
  background: #2f3b4d;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  color: var(--ink);
}

[data-theme="dark"] .bubble.negative {
  background: linear-gradient(180deg, #3a2a30 0%, #2f262c 100%);
  border-color: rgba(255, 120, 120, 0.28);
}

[data-theme="dark"] .bubble.positive {
  background: linear-gradient(180deg, #243530 0%, #222e29 100%);
  border-color: rgba(102, 212, 174, 0.28);
}

[data-theme="dark"] .bubble.handled {
  opacity: 0.78;
}

[data-theme="dark"] .bubble-meta {
  color: var(--ink-soft);
}

[data-theme="dark"] .bubble-meta .author {
  color: #e4ebf6;
}

[data-theme="dark"] .bubble-meta time {
  color: #9eb0c8;
}

[data-theme="dark"] .sentiment-tag.negative {
  background: rgba(255, 120, 120, 0.2);
  color: #ffb3b3;
}

[data-theme="dark"] .sentiment-tag.neutral {
  background: rgba(168, 184, 206, 0.18);
  color: #c7d4e6;
}

[data-theme="dark"] .sentiment-tag.positive {
  background: rgba(102, 212, 174, 0.18);
  color: #8ce8c8;
}

[data-theme="dark"] .msg-type {
  background: rgba(114, 182, 255, 0.16);
  color: #a8d0ff;
  border: 1px solid rgba(114, 182, 255, 0.22);
}

[data-theme="dark"] .msg-type.question,
[data-theme="dark"] .msg-type.complaint {
  background: rgba(255, 176, 96, 0.16);
  color: #ffc98a;
  border: 1px solid rgba(255, 176, 96, 0.22);
}

[data-theme="dark"] .msg-type.thanks,
[data-theme="dark"] .msg-type.gratitude {
  background: rgba(102, 212, 174, 0.16);
  color: #8ce8c8;
  border: 1px solid rgba(102, 212, 174, 0.22);
}

[data-theme="dark"] .addr-tag {
  background: rgba(114, 182, 255, 0.14);
  color: #a8d0ff;
  border: 1px solid rgba(114, 182, 255, 0.24);
}

[data-theme="dark"] .label-actions button {
  background: #364355;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--ink-soft);
}

[data-theme="dark"] .label-actions button:hover {
  background: #425268;
  color: var(--ink);
}

[data-theme="dark"] .ctx-pill {
  background: #243040;
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ctx-pill.warn {
  color: #ffb3b3;
  background: rgba(255, 120, 120, 0.14);
  border-color: rgba(255, 120, 120, 0.24);
}

[data-theme="dark"] .ctx-pill.hot {
  color: #ffc98a;
  background: rgba(255, 176, 96, 0.14);
  border-color: rgba(255, 176, 96, 0.24);
}

[data-theme="dark"] .ctx-pill.ok {
  color: #8ce8c8;
  background: rgba(102, 212, 174, 0.14);
  border-color: rgba(102, 212, 174, 0.24);
}

[data-theme="dark"] .ctx-pill.muted {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .chip-filter {
  color: var(--ink-soft);
}

[data-theme="dark"] .chip-filter.active {
  color: #fff;
}

[data-theme="dark"] .period-btn {
  color: var(--ink-soft);
}

[data-theme="dark"] .period-btn.active {
  background: var(--accent);
  color: #0d1117;
}

[data-theme="dark"] .top-row,
[data-theme="dark"] .rank-item {
  background: #243040;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .top-row:hover {
  background: #2b384a;
}

[data-theme="dark"] .top-rank {
  background: #364355;
  color: var(--ink-soft);
}

[data-theme="dark"] .top-row:nth-child(1) .top-rank {
  background: rgba(255, 120, 120, 0.2);
  color: #ffb3b3;
}

[data-theme="dark"] .top-row:nth-child(2) .top-rank {
  background: rgba(255, 176, 96, 0.18);
  color: #ffc98a;
}

[data-theme="dark"] .top-row:nth-child(3) .top-rank {
  background: rgba(114, 182, 255, 0.18);
  color: #a8d0ff;
}

[data-theme="dark"] .top-sub,
[data-theme="dark"] .rank-meta,
[data-theme="dark"] .panel-lead,
[data-theme="dark"] .kpi-label,
[data-theme="dark"] .kpi-hint,
[data-theme="dark"] .bar-label {
  color: var(--ink-soft);
}

[data-theme="dark"] .category-chat {
  background: rgba(114, 182, 255, 0.12);
  color: #a8d0ff;
}

[data-theme="dark"] .category-status.wait {
  color: #ffb3b3;
  background: rgba(255, 120, 120, 0.14);
  border-color: rgba(255, 120, 120, 0.22);
}

[data-theme="dark"] .category-status.done {
  color: #8ce8c8;
  background: rgba(102, 212, 174, 0.14);
  border-color: rgba(102, 212, 174, 0.22);
}

[data-theme="dark"] .category-msg {
  background: #2f3b4d;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tab {
  color: var(--ink-soft);
}

[data-theme="dark"] .tab.active {
  color: var(--accent);
  background: rgba(114, 182, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(114, 182, 255, 0.18);
}

[data-theme="dark"] .btn.soft-neg {
  background: rgba(255, 120, 120, 0.16);
  color: #ffb3b3;
}

[data-theme="dark"] .btn.soft-pos {
  background: rgba(102, 212, 174, 0.16);
  color: #8ce8c8;
}

[data-theme="dark"] .msg-highlight .bubble {
  outline-color: rgba(114, 182, 255, 0.75);
}

@media (max-width: 840px) {
  .topic-chips {
    padding: 0 0.75rem 0.65rem;
  }

  .page-head-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* —— Аналитика каналов Max —— */
.channels-page-head {
  max-width: 1600px;
  margin: 0.75rem auto 0.85rem;
  padding: 0 1rem;
  width: 100%;
}

.channels-hero {
  width: 100%;
  text-align: center;
  padding: 1.25rem 1.75rem 1.15rem;
  border-radius: 22px;
  border: 1px solid rgba(20, 50, 70, 0.12);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.78) 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 16px 40px rgba(20, 50, 70, 0.1);
  backdrop-filter: blur(14px);
}

.channels-hero-title {
  margin: 0;
  font-family: Montserrat, sans-serif;
  font-size: clamp(1.75rem, 3.2vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--ink);
  text-transform: none;
}

.channels-hero-desc {
  margin: 0.55rem auto 0;
  max-width: 42rem;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.channels-hero-period {
  margin: 1rem auto 0;
  justify-content: center;
}

.channels-page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1rem 6.5rem;
}

.channels-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}

.ch-summary {
  margin-bottom: 1rem;
}

.ch-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.ch-kpi-grid .ch-metric {
  --ch-accent: #0f8b8d;
  min-height: 0;
}

.ch-kpi-grid-card {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 0.65rem;
}

.ch-charts-block {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  padding: 0.85rem 0.9rem;
  box-shadow: 0 8px 24px rgba(20, 50, 70, 0.06);
}

.ch-summary-panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: 0 14px 36px rgba(20, 50, 70, 0.08);
}

.ch-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.ch-section-head h2 {
  margin: 0;
  font-family: Montserrat, sans-serif;
  font-size: 1.28rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.ch-section-head p {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.ch-metrics-summary {
  margin-bottom: 1rem;
}

.ch-metrics-summary .ch-metric {
  background: #fff;
  border: 1px solid rgba(20, 50, 70, 0.1);
  box-shadow: 0 8px 20px rgba(20, 50, 70, 0.05);
}

.ch-summary .ch-overview {
  margin-bottom: 0;
}

.ch-overview-charts {
  grid-template-columns: 1.15fr 1.15fr 0.9fr;
  gap: 0.85rem;
  align-items: start;
}

.ch-summary .ch-overview-card {
  background: #fff;
  border: 1px solid rgba(20, 50, 70, 0.1);
  border-radius: 16px;
  padding: 0.85rem 0.9rem 0.75rem;
  box-shadow: 0 8px 20px rgba(20, 50, 70, 0.04);
}

.ch-channels-section {
  margin-top: 1.1rem;
}

.ch-channels-section .ch-grid {
  gap: 0.65rem;
}

.ch-vbar {
  width: 100%;
}

.ch-vbar-val {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
  font-family: Montserrat, sans-serif;
}

.ch-vbar-label {
  fill: var(--ink-soft);
  font-size: 10px;
  font-family: Inter, sans-serif;
}

.ch-donut {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: center;
}

.ch-donut-svg {
  display: block;
}

.ch-donut-center {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 800;
  font-family: Montserrat, sans-serif;
}

.ch-donut-sub {
  fill: var(--ink-soft);
  font-size: 10px;
  font-family: Inter, sans-serif;
}

.ch-donut-legend {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.ch-donut-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.74rem;
}

.ch-donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.ch-donut-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  color: var(--ink);
}

.ch-donut-name > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-donut-item strong {
  font-family: Montserrat, sans-serif;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.ch-posts-tiles {
  display: grid;
  gap: 0.55rem;
}

.ch-post-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--ch-accent, #0f8b8d) 18%, var(--line));
  background: color-mix(in srgb, var(--ch-accent, #0f8b8d) 6%, #fff);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ch-post-tile:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--ch-accent, #0f8b8d) 40%, var(--line));
  box-shadow: 0 6px 16px rgba(20, 50, 70, 0.08);
}

.ch-post-tile.is-static {
  cursor: default;
}

.ch-post-rank {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: Montserrat, sans-serif;
  font-size: 0.78rem;
  font-weight: 750;
  color: #fff;
  background: var(--ch-accent, #0f8b8d);
  flex-shrink: 0;
}

.ch-post-body {
  min-width: 0;
}

.ch-post-text {
  font-size: 0.8rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.ch-post-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.ch-post-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  min-width: 4px;
}

.ch-post-meta {
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.ch-chart-posts {
  grid-column: 1 / -1;
}

.ch-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.ch-overview.ch-overview-charts {
  grid-template-columns: 1fr 1fr 1.05fr;
}

.ch-overview-card,
.ch-card {
  --ch-accent: #0f8b8d;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 0 10px 28px rgba(20, 50, 70, 0.06);
}

.ch-overview-card h3,
.ch-chart-title {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.ch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.ch-card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.ch-avatar {
  width: 42px;
  height: 42px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.ch-card-titles {
  min-width: 0;
  flex: 1;
}

.ch-card-titles h3 {
  margin: 0;
  font-family: Montserrat, sans-serif;
  font-size: 1.12rem;
  font-weight: 750;
  line-height: 1.2;
}

.ch-link {
  display: inline-block;
  margin-top: 0.12rem;
  font-size: 0.76rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.ch-link:hover { color: var(--accent); }

.ch-card-stamp {
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.ch-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.95rem;
}

.ch-metric {
  position: relative;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ch-accent) 22%, var(--line));
  border-radius: 16px;
  background:
    linear-gradient(145deg,
      color-mix(in srgb, var(--ch-accent) 14%, #fff) 0%,
      color-mix(in srgb, var(--ch-accent) 4%, #fff) 55%,
      rgba(255, 255, 255, 0.92) 100%);
  padding: 0.85rem 0.95rem 0.8rem;
  min-height: 6.4rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ch-metric::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--ch-accent);
  opacity: 0.85;
}

.ch-metric.is-compact {
  min-height: 0;
  padding: 0.5rem 0.55rem 0.48rem;
  border-radius: 11px;
  cursor: default;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.ch-metric.is-compact::before {
  width: 3px;
}

.ch-metric.is-compact .ch-metric-label {
  font-size: 0.64rem;
  line-height: 1.25;
  margin-bottom: 0.12rem;
}

.ch-metric.is-compact .ch-metric-value {
  font-size: 1.08rem;
  line-height: 1.1;
}

.ch-metric.is-compact.is-accent {
  min-height: 0;
}

.ch-metric.is-compact.is-accent .ch-metric-value {
  font-size: 1.18rem;
}

.ch-metric.is-compact .ch-metric-delta {
  margin-top: 0.2rem;
}

.ch-metric.is-compact .ch-metric-delta-val {
  font-size: 0.72rem;
}

.ch-metric.is-compact .ch-metric-hint {
  display: none;
}

.ch-card-compact {
  padding: 0.75rem 0.85rem 0.8rem;
  border-radius: 16px;
}

.ch-card-compact .ch-card-head {
  margin-bottom: 0.55rem;
}

.ch-card-compact .ch-avatar {
  width: 34px;
  height: 34px;
  font-size: 0.68rem;
}

.ch-card-compact .ch-card-titles h3 {
  font-size: 0.92rem;
}

.ch-card-compact .ch-link {
  font-size: 0.68rem;
}

.ch-card-compact .ch-card-stamp {
  font-size: 0.64rem;
}

.ch-charts-compact {
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0;
}

.ch-charts-compact .ch-chart {
  padding: 0.45rem 0.5rem 0.4rem;
}

.ch-charts-compact .ch-chart-title {
  font-size: 0.72rem;
  margin-bottom: 0.35rem;
}

.ch-charts-compact .ch-chart-posts {
  grid-column: 1 / -1;
}

.ch-charts-compact .ch-post-tile {
  padding: 0.45rem 0.55rem;
}

.ch-charts-compact .ch-post-text {
  font-size: 0.72rem;
}

.ch-metric.is-accent {
  min-height: 7.2rem;
  border-color: color-mix(in srgb, var(--ch-accent) 35%, var(--line));
  background:
    linear-gradient(145deg,
      color-mix(in srgb, var(--ch-accent) 22%, #fff) 0%,
      color-mix(in srgb, var(--ch-accent) 8%, #fff) 48%,
      #fff 100%);
}

.ch-metric.is-up::before { background: #1a9f6d; }
.ch-metric.is-down::before { background: #d64545; }

.ch-metric-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.ch-metric-label {
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--ink-soft);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.ch-metric-dot {
  width: 8px;
  height: 8px;
  margin-top: 0.25rem;
  border-radius: 50%;
  background: var(--ch-accent);
  opacity: 0.55;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ch-accent) 16%, transparent);
}

.ch-metric-value {
  font-family: Montserrat, sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.ch-metric.is-accent .ch-metric-value {
  font-size: 1.85rem;
}

.ch-metric-value.up { color: #168a5c; }
.ch-metric-value.down { color: #c53c3c; }
.ch-metric-value.flat { color: var(--ink-soft); }

.ch-metric-delta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin-top: 0.4rem;
}

.ch-metric-delta-val {
  font-family: Montserrat, sans-serif;
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.2;
}

.ch-metric-delta-label {
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.ch-metric-delta.up .ch-metric-delta-val { color: #168a5c; }
.ch-metric-delta.down .ch-metric-delta-val { color: #c53c3c; }
.ch-metric-delta.flat .ch-metric-delta-val,
.ch-metric-delta.muted .ch-metric-delta-val { color: var(--ink-soft); }

.ch-metric-hint {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

.ch-charts {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0.75rem;
}

.ch-chart {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  padding: 0.7rem 0.75rem 0.55rem;
  min-width: 0;
}

.ch-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.ch-grid-line,
.ch-chart-svg .ch-grid {
  stroke: rgba(20, 40, 60, 0.08);
  stroke-width: 1;
}

.ch-axis {
  fill: var(--ink-soft);
  font-size: 9px;
  font-family: Inter, sans-serif;
}

.ch-area {
  opacity: 0.14;
}

.ch-chart-legend,
.ch-chart-empty {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.ch-chart-empty {
  padding: 0.55rem 0.15rem 0.35rem;
}

.ch-hbar {
  display: grid;
  gap: 0.4rem;
}

.ch-hbar-stack {
  gap: 0.7rem;
}

.ch-hbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
  gap: 0.45rem;
  align-items: center;
}

.ch-hbar-row-stack {
  grid-template-columns: 1fr;
  gap: 0.28rem;
}

.ch-hbar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  min-width: 0;
}

.ch-hbar-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-size: 0.74rem;
  line-height: 1.25;
  color: var(--ink);
  overflow: hidden;
}

.ch-hbar-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-hbar-label .ch-plat-pill {
  flex: 0 0 auto;
}

.ch-hbar-stack .ch-hbar-label {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  flex-wrap: wrap;
  align-items: center;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
}

.ch-hbar-stack .ch-hbar-name {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.ch-hbar-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
}

.ch-hbar-stack .ch-hbar-track {
  height: 12px;
}

.ch-hbar-fill {
  height: 100%;
  border-radius: inherit;
  min-width: 3px;
}

.ch-hbar-val {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  text-align: right;
}

.ch-hbar-stack .ch-hbar-val {
  font-size: 0.88rem;
  color: var(--ink);
  flex-shrink: 0;
}

.ch-posts-compact {
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.ch-posts-compact ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.ch-posts-compact li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.ch-posts-compact a {
  color: inherit;
  text-decoration: none;
}

.ch-posts-compact a:hover { color: var(--accent); }

.ch-posts-compact span {
  color: var(--ink-soft);
  white-space: nowrap;
  font-size: 0.72rem;
}

[data-theme="dark"] .ch-charts-block,
[data-theme="dark"] .ch-overview-card,
[data-theme="dark"] .ch-card,
[data-theme="dark"] .ch-chart,
[data-theme="dark"] .ch-summary-panel,
[data-theme="dark"] .ch-metrics-summary .ch-metric,
[data-theme="dark"] .ch-summary .ch-overview-card,
[data-theme="dark"] .channels-hero {
  background: rgba(18, 26, 36, 0.72);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

[data-theme="dark"] .ch-post-tile {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ch-post-bar {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ch-metric {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

[data-theme="dark"] .ch-metric.is-accent {
  background: linear-gradient(145deg, color-mix(in srgb, var(--ch-accent) 28%, transparent), rgba(255, 255, 255, 0.04));
}

[data-theme="dark"] .ch-hbar-track {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ch-chart-svg .ch-grid {
  stroke: rgba(255, 255, 255, 0.08);
}

@media (max-width: 1400px) {
  .ch-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .ch-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .ch-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .ch-overview,
  .ch-overview-charts,
  .ch-charts,
  .ch-charts-compact,
  .ch-grid {
    grid-template-columns: 1fr;
  }
  .ch-kpi-grid,
  .ch-kpi-grid-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ch-donut {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

@media (max-width: 640px) {
  .ch-kpi-grid,
  .ch-kpi-grid-card {
    grid-template-columns: 1fr 1fr;
  }
  .ch-metric,
  .ch-metric.is-accent {
    min-height: 0;
  }
  .ch-metric-value {
    font-size: 1.4rem;
  }
  .ch-metric.is-accent .ch-metric-value {
    font-size: 1.6rem;
  }
  .ch-card-stamp {
    display: none;
  }
  .ch-hbar-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .ch-posts-compact li {
    flex-direction: column;
    gap: 0.1rem;
  }
}

.ch-net {
  margin: 0 0 1.35rem;
}

details.ch-net {
  display: block;
}

details.ch-net > .ch-net-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

details.ch-net > .ch-net-summary::-webkit-details-marker,
details.ch-net > .ch-net-summary::marker {
  display: none;
  content: none;
}

.ch-net-chevron {
  margin-left: auto;
  display: grid;
  place-items: center;
}

.ch-net-body {
  margin-top: 0.7rem;
}

.ch-net-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.65rem;
}

.ch-net-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

.ch-net-head p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.ch-net-empty {
  padding: 1.1rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.ch-grid-tiles {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ch-tile .ch-charts-compact {
  grid-template-columns: 1fr;
}

.ch-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  margin-top: 0.18rem;
}

.ch-title-link {
  color: inherit;
  text-decoration: none;
}

.ch-title-link:hover {
  color: var(--accent);
}

.ch-plat-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.42rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.ch-plat-max { background: rgba(232, 137, 117, 0.18); color: #c45c3a; }
.ch-plat-telegram { background: rgba(47, 111, 237, 0.14); color: #2f6fed; }
.ch-plat-vk { background: rgba(70, 128, 194, 0.16); color: #3b6ea5; }

.ch-activity {
  height: 6px;
  border-radius: 99px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
  margin: 0.15rem 0 0.55rem;
}

.ch-activity-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ch-accent, #e88975);
}

.ch-sent {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.ch-sent-chip {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.ch-sent-chip span {
  font-size: 0.68rem;
  color: var(--ink-soft);
}

.ch-sent-chip strong {
  font-size: 0.95rem;
}

.ch-sent-chip.is-neg { border-color: rgba(196, 92, 92, 0.35); }
.ch-sent-chip.is-pos { border-color: rgba(47, 157, 106, 0.35); }

.ch-posts-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.ch-posts-tiles.is-worst .ch-post-bar span {
  opacity: 0.75;
}

@media (max-width: 1100px) {
  .ch-grid-tiles,
  .ch-posts-split {
    grid-template-columns: 1fr;
  }
}
