:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-soft: #f9f4ec;
  --line: rgba(76, 57, 35, 0.12);
  --text: #20170f;
  --muted: #756456;
  --accent: #1b74e4;
  --accent-soft: #e8f1ff;
  --page-accent: #2563eb;
  --page-accent-soft: #eaf1ff;
  --page-accent-ink: #113f8c;
  --page-wash: rgba(37, 99, 235, 0.08);
  --danger: #9d2b2b;
  --danger-soft: #f6e2de;
  --shadow: 0 24px 56px rgba(44, 31, 22, 0.1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at top left, rgba(27, 116, 228, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(197, 147, 88, 0.16), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.shell {
  min-height: 100vh;
  height: 100vh;
}

.shell.auth-loading .login-panel {
  display: none;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.sidebar,
.topbar,
.sidebar-card,
.conversation-card,
.empty-state,
.info-card,
.panel-card {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-card {
  width: min(520px, 100%);
  border-radius: 28px;
  padding: 36px;
}

.login-logo {
  display: block;
  width: min(300px, 82%);
  height: auto;
  margin: 0 auto 8px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
}

.muted { color: var(--muted); }

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: center;
  margin-top: 18px;
  font-size: 13px;
}

.login-legal-links a,
.legal-document a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.login-legal-links a:hover,
.legal-document a:hover {
  text-decoration: underline;
}

.legal-page {
  min-height: 100vh;
  height: auto;
  padding: 32px 18px;
}

.legal-document {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.legal-logo {
  display: block;
  width: min(260px, 70%);
  height: auto;
  margin: 0 0 20px;
}

.legal-document h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
}

.legal-document h2 {
  margin: 28px 0 8px;
  font-size: 19px;
}

.legal-document p {
  margin: 0 0 14px;
  line-height: 1.65;
}

.login-form label {
  display: grid;
  gap: 8px;
}

input, textarea, select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--page-accent-soft);
  border-color: var(--page-accent);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: var(--page-accent, var(--accent));
  color: #f9fffe;
  font-weight: 700;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger { background: var(--danger); color: #fff; }
.danger-soft { background: var(--danger-soft); color: var(--danger); }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 14px; }
.success-text { color: var(--accent); }

.app {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.app.page-context-dashboard {
  --page-accent: #2563eb;
  --page-accent-soft: #eaf1ff;
  --page-accent-ink: #113f8c;
  --page-wash: rgba(37, 99, 235, 0.08);
}

.app.page-context-channels {
  --page-accent: #1b74e4;
  --page-accent-soft: #e8f1ff;
  --page-accent-ink: #1057ad;
  --page-wash: rgba(27, 116, 228, 0.08);
}

.app.page-context-whatsappLinks {
  --page-accent: #0f766e;
  --page-accent-soft: #dffcf7;
  --page-accent-ink: #115e59;
  --page-wash: rgba(15, 118, 110, 0.08);
}

.app.page-context-assistants {
  --page-accent: #7c3aed;
  --page-accent-soft: #f0e9ff;
  --page-accent-ink: #4c1d95;
  --page-wash: rgba(124, 58, 237, 0.08);
}

.app.page-context-inbox {
  --page-accent: #0f2f63;
  --page-accent-soft: #e8f1ff;
  --page-accent-ink: #0b1f3e;
  --page-wash: rgba(15, 47, 99, 0.08);
}

.app.page-context-contacts {
  --page-accent: #0e7490;
  --page-accent-soft: #e3f6fb;
  --page-accent-ink: #155e75;
  --page-wash: rgba(14, 116, 144, 0.08);
}

.app.page-context-stores {
  --page-accent: #2563eb;
  --page-accent-soft: #eaf1ff;
  --page-accent-ink: #113f8c;
  --page-wash: rgba(37, 99, 235, 0.08);
}

.app.page-context-triggers {
  --page-accent: #b45309;
  --page-accent-soft: #fff4df;
  --page-accent-ink: #78350f;
  --page-wash: rgba(180, 83, 9, 0.08);
}

.app.page-context-flows {
  --page-accent: #1b74e4;
  --page-accent-soft: #e8f1ff;
  --page-accent-ink: #1057ad;
  --page-wash: rgba(27, 116, 228, 0.08);
}

.app.page-context-templates {
  --page-accent: #c05621;
  --page-accent-soft: #fff0e5;
  --page-accent-ink: #8a3b12;
  --page-wash: rgba(192, 86, 33, 0.1);
}

.app.page-context-campaigns {
  --page-accent: #be123c;
  --page-accent-soft: #ffe4ec;
  --page-accent-ink: #881337;
  --page-wash: rgba(190, 18, 60, 0.08);
}

.app.page-context-notifications {
  --page-accent: #7c2d12;
  --page-accent-soft: #ffedd5;
  --page-accent-ink: #431407;
  --page-wash: rgba(124, 45, 18, 0.08);
}

.app.page-context-settings {
  --page-accent: #4f46e5;
  --page-accent-soft: #ecebff;
  --page-accent-ink: #312e81;
  --page-wash: rgba(79, 70, 229, 0.08);
}

.app.console-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar {
  border-radius: 0 28px 28px 0;
  padding: 22px 18px;
  border-left: 0;
  min-height: 100vh;
  height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, #0f2f63 0%, #102a52 52%, #0b1f3e 100%);
  color: #f8fbff;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 14px 0 36px rgba(6, 22, 48, 0.32);
}

.sidebar .eyebrow {
  color: rgba(248, 251, 255, 0.62);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-logo {
  display: block;
  width: min(174px, 100%);
  height: auto;
  object-fit: contain;
}

.sidebar-toggle,
.chat-list-toggle {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  line-height: 1;
}

.sidebar .sidebar-toggle {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.app.console-collapsed .sidebar {
  padding: 14px 8px;
}

.app.console-collapsed .brand {
  justify-content: center;
}

.app.console-collapsed .sidebar-logo {
  display: none;
}

.app.console-collapsed .nav {
  margin-top: 16px;
}

.app.console-collapsed .nav-item {
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 0;
}

.app.console-collapsed .nav-item::before {
  margin: 0;
  width: auto;
  font-size: 20px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.nav-item {
  position: relative;
  text-align: left;
  background: transparent;
  color: rgba(248, 251, 255, 0.9);
  border: 1px solid transparent;
  padding-right: 42px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item::before {
  content: attr(data-icon);
  width: 20px;
  min-width: 20px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  font-size: 17px;
  line-height: 1;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 4px 0 0 #7dd3fc;
}

.nav-item:not(.active):hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.has-unread::after,
.mobile-nav-item.has-unread::after {
  content: attr(data-unread);
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}

.app.console-collapsed .nav-item.has-unread::after {
  right: 3px;
  top: 7px;
  transform: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
}

.main {
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--page-wash), transparent 280px);
}

.topbar {
  border-radius: 28px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-top: 4px solid var(--page-accent);
}

.topbar h1 { margin: 0; font-size: 34px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.app.is-inbox .main {
  padding: 10px 12px;
  gap: 8px;
}

.app.is-inbox .topbar {
  border-radius: 20px;
  padding: 10px 14px;
}

.app.is-inbox .topbar .eyebrow {
  margin-bottom: 3px;
  font-size: 10px;
}

.app.is-inbox .topbar h1 {
  font-size: 24px;
  line-height: 1.05;
}

.app.is-inbox .topbar .pill,
.app.is-inbox .topbar .ghost-button {
  padding: 7px 10px;
  font-size: 12px;
}

.mobile-nav {
  display: none;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.ws-status.connected {
  color: var(--accent);
  background: var(--accent-soft);
}

.ws-status.disconnected {
  color: var(--danger);
  background: var(--danger-soft);
}

.sound-status {
  cursor: pointer;
  color: var(--danger);
  background: var(--danger-soft);
}

.sound-status.sound-ready {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge.warning {
  color: #8a5b00;
  background: #fff2cc;
  border-color: #f0cf76;
}

.status-alert {
  display: grid;
  gap: 4px;
  margin: 0 auto 12px;
  max-width: 720px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13px;
}

.status-alert.warning {
  color: #6f4c00;
  background: #fff7df;
  border-color: #f0cf76;
}

.page { display: none; min-height: 0; height: 100%; overflow: auto; }
.page.active { display: block; }
.page[data-page="inbox"] {
  overflow: auto;
}

.page[data-page="inbox"].active {
  display: flex;
  flex-direction: column;
}

.stats-grid,
.cards-grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}

.stat-card,
.info-card,
.panel-card {
  border-radius: 24px;
  padding: 18px;
}

.panel-card {
  border-top: 3px solid color-mix(in srgb, var(--page-accent) 28%, transparent);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-top: 4px solid var(--page-accent);
}

.stat-card strong {
  display: block;
  font-size: 34px;
  margin-top: 4px;
}

.stat-card.stat-ok { border-top-color: #1b74e4; }
.stat-card.stat-warning { border-top-color: #c47f00; }
.stat-card.stat-danger { border-top-color: var(--danger); }
.stat-card.stat-purple { border-top-color: #7c3aed; }
.stat-card.stat-orange { border-top-color: #c05621; }
.stat-card.stat-blue { border-top-color: #2563eb; }

.cards-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dashboard-page {
  display: grid;
  gap: 16px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--page-accent);
  border-radius: 24px;
  background: linear-gradient(180deg, #fff, var(--page-accent-soft));
  box-shadow: var(--shadow);
}

.dashboard-kicker,
.dashboard-focus-label {
  display: block;
  color: var(--page-accent-ink);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-hero h2 {
  margin: 8px 0 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.06;
  max-width: 880px;
}

.dashboard-focus {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.dashboard-focus strong {
  font-size: 24px;
}

.dashboard-focus small {
  color: var(--muted);
}

.dashboard-stats-grid {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

.dashboard-grid-bottom {
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
}

.dashboard-panel {
  border-top: 4px solid var(--page-accent);
}

.dashboard-attention-list,
.dashboard-module-grid,
.dashboard-campaigns,
.dashboard-health {
  display: grid;
  gap: 10px;
}

.dashboard-attention-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
}

.dashboard-attention-item span {
  font-size: 22px;
  font-weight: 800;
}

.dashboard-attention-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.dashboard-attention-item.tone-warning { border-color: #e7bf69; background: #fff7df; }
.dashboard-attention-item.tone-danger { border-color: #e9aaa4; background: #fff0ee; }
.dashboard-attention-item.tone-info { border-color: #b8d3ff; background: #edf5ff; }

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

.dashboard-module-item,
.dashboard-health-row,
.dashboard-last-campaign,
.dashboard-campaign-grid > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.dashboard-legal-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.dashboard-legal-link:hover {
  border-color: var(--blue-500);
  box-shadow: 0 10px 24px rgba(26, 94, 160, 0.14);
  transform: translateY(-1px);
}

.dashboard-module-item span,
.dashboard-health-row span,
.dashboard-last-campaign span,
.dashboard-campaign-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-module-item strong,
.dashboard-campaign-grid strong {
  font-size: 24px;
  line-height: 1;
}

.dashboard-module-item small,
.dashboard-health-row small,
.dashboard-last-campaign small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dashboard-campaign-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-last-campaign strong {
  font-size: 18px;
}

.dashboard-health-row {
  grid-template-columns: minmax(140px, 0.7fr) minmax(80px, auto) minmax(0, 1fr);
  align-items: center;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head-stack {
  align-items: flex-start;
}

.inbox-filterbar {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(110px, 150px) minmax(210px, 260px) minmax(170px, 230px);
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.app.is-inbox .inbox-filterbar {
  grid-template-columns: minmax(170px, 220px) minmax(110px, 150px) minmax(210px, 260px) minmax(170px, 230px);
  margin-bottom: 8px;
}

.filter-control {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
}

.inbox-filterbar button.filter-control {
  width: auto;
  white-space: nowrap;
}

.filter-control.primary,
.filter-control.active {
  color: #0b63ce;
  border-color: #b8d3ff;
  background: #edf5ff;
}

.filter-control:disabled {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.inbox-bulk-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  min-height: 0;
  max-height: 420px;
  overflow: auto;
  flex: 0 0 auto;
}

.inbox-bulk-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.inbox-bulk-head strong,
.inbox-bulk-head span {
  display: block;
}

.inbox-bulk-head span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.inbox-bulk-grid {
  display: grid;
  grid-template-columns: minmax(430px, 0.85fr) minmax(460px, 1.15fr);
  gap: 14px;
  min-width: 0;
}

.inbox-bulk-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.inbox-bulk-number {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  min-width: 0;
}

.inbox-bulk-number input {
  width: 15px;
  height: 15px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.inbox-bulk-number strong,
.inbox-bulk-number small {
  display: block;
}

.inbox-bulk-number strong {
  font-size: 12px;
}

.inbox-bulk-number small {
  color: var(--muted);
  font-size: 11px;
}

.inbox-bulk-compose {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.inbox-bulk-compose textarea {
  min-height: 118px;
  resize: vertical;
}

.filter-check {
  width: 28px;
  height: 34px;
  display: grid;
  place-items: center;
}

.filter-check input {
  width: 16px;
  height: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  flex: 1;
  height: calc(100vh - 202px);
  max-height: calc(100vh - 202px);
  min-height: 0;
  align-items: stretch;
}

.app.is-inbox .workspace {
  gap: 10px;
  height: calc(100vh - 136px);
  max-height: calc(100vh - 136px);
  flex: 0 0 calc(100vh - 136px);
}

.app.chat-list-collapsed .workspace {
  grid-template-columns: 52px minmax(0, 1fr);
}

.conversation {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
}

.sidebar-card,
.conversation-card,
.empty-state {
  border-radius: 26px;
  min-height: 0;
}

.sidebar-card {
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sidebar-head-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.app.is-inbox .sidebar-card,
.app.is-inbox .conversation-card,
.app.is-inbox .empty-state {
  border-radius: 18px;
}

.app.is-inbox .sidebar-card {
  padding: 10px;
}

.app.chat-list-collapsed .sidebar-card {
  padding: 8px;
  grid-template-rows: auto;
}

.app.chat-list-collapsed .sidebar-head {
  justify-content: center;
  margin-bottom: 0;
}

.app.chat-list-collapsed .sidebar-head-title,
.app.chat-list-collapsed #chat-search,
.app.chat-list-collapsed .chat-list {
  display: none;
}

.chat-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 0;
  scrollbar-gutter: stable;
}

.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(135deg, #123765, #0f2f63);
  color: #fff;
  border-radius: 16px;
  padding: 12px 42px 12px 12px;
}

.chat-item.manual {
  border-color: #facc15;
  box-shadow:
    inset 4px 0 0 #facc15,
    0 10px 22px rgba(250, 204, 21, 0.2);
  padding-right: 94px;
}

.chat-item.active {
  background: linear-gradient(135deg, #184575, #102a52);
  box-shadow: inset 4px 0 0 rgba(255,255,255,.94);
}

.chat-item.unread {
  border-color: #dc2626;
  box-shadow:
    inset 4px 0 0 #dc2626,
    0 10px 22px rgba(220, 38, 38, 0.18);
}

.chat-item.unread::after {
  content: "!";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.96);
}

.chat-item.manual.unread::after {
  top: auto;
  bottom: 10px;
  transform: none;
}

.chat-manual-alert {
  position: absolute;
  top: 10px;
  right: 12px;
  display: inline-grid;
  place-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #facc15;
  color: #3a2a00;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92);
}

.chat-item-row,
.chat-item-side {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.chat-item-side {
  flex-direction: column;
  align-items: flex-end;
}

.chat-preview { font-size: 12px; color: rgba(255,255,255,.84); }
.chat-time { font-size: 11px; color: rgba(255,255,255,.92); }

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
  height: 100%;
}

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

.conversation-head,
.composer {
  padding: 16px;
}

.app.is-inbox .conversation-head,
.app.is-inbox .composer {
  padding: 8px 10px;
}

.conversation-head {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.conversation-head-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.conversation-head h3 {
  margin: 0;
  font-size: 28px;
}

.app.is-inbox .conversation-head h3 {
  font-size: 20px;
  line-height: 1.05;
}

.control-row,
.badges,
.composer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.conversation-actions {
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.conversation-actions .ghost-button,
.conversation-actions .danger,
.conversation-actions .danger-soft {
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
}

.app.is-inbox .badges {
  gap: 6px;
  margin-top: 4px;
}

.app.is-inbox .badge {
  padding: 5px 10px;
  font-size: 12px;
}

.composer-actions select {
  width: auto;
  min-width: 130px;
}

.message-stream {
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  scrollbar-gutter: stable;
  background:
    linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,.04)),
    rgba(255,255,255,.42);
}

.app.is-inbox .message-stream {
  padding: 12px;
}

.conversation-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  overflow: hidden;
}

.app.is-inbox .conversation-body {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.app.is-inbox.order-progress-collapsed .conversation-body {
  grid-template-columns: minmax(0, 1fr) 46px;
}

.app.social-inbox #inbox-channel-filter,
.app.social-inbox .inbox-bulk-panel,
.app.social-inbox .order-progress-panel {
  display: none;
}

.app.social-inbox .conversation-body,
.app.social-inbox.order-progress-collapsed .conversation-body {
  grid-template-columns: minmax(0, 1fr);
}

.order-progress-panel {
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  overflow: auto;
  padding: 14px;
  min-width: 0;
  position: relative;
}

.app.is-inbox .order-progress-panel {
  padding: 10px;
}

.order-progress-toggle {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #0f2f63;
  display: inline-grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  margin: -2px 0 0;
  padding: 0;
}

.order-progress-toggle:hover {
  background: rgba(15, 47, 99, 0.08);
}

.app.order-progress-collapsed .order-progress-panel {
  overflow: hidden;
  padding: 8px;
}

.app.order-progress-collapsed .order-progress-head {
  justify-content: center;
  margin-bottom: 0;
}

.app.order-progress-collapsed .order-progress-head > div,
.app.order-progress-collapsed .order-progress-table {
  display: none;
}

.order-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.order-progress-head strong {
  display: block;
  font-size: 14px;
}

.order-progress-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.order-progress-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.order-progress-table tr {
  background: #fff7df;
  outline: 1px solid #f0cf76;
}

.order-progress-table tr.ok {
  background: #e8f1ff;
  outline-color: #93b7e8;
}

.order-progress-table tr.warning {
  background: #ffe9e7;
  outline-color: #f0aaa3;
}

.order-progress-table td {
  padding: 10px;
  vertical-align: top;
}

.order-progress-table td:first-child {
  border-radius: 8px 0 0 8px;
}

.order-progress-table td:last-child {
  border-radius: 0 8px 8px 0;
}

.order-step-index {
  width: 26px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.order-progress-table strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.order-progress-table span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 4px;
}

.order-step-status {
  width: 74px;
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  color: #8a6700;
}

.order-progress-table tr.ok .order-step-status {
  color: #1057ad;
}

.order-progress-table tr.warning .order-step-status {
  color: #b23b33;
}

.chat-list::-webkit-scrollbar,
.message-stream::-webkit-scrollbar,
.order-progress-panel::-webkit-scrollbar,
.channel-form-card::-webkit-scrollbar,
.page::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.chat-list::-webkit-scrollbar-thumb,
.message-stream::-webkit-scrollbar-thumb,
.order-progress-panel::-webkit-scrollbar-thumb,
.channel-form-card::-webkit-scrollbar-thumb,
.page::-webkit-scrollbar-thumb {
  background: rgba(117, 100, 86, 0.35);
  border-radius: 999px;
}

.chat-list::-webkit-scrollbar-track,
.message-stream::-webkit-scrollbar-track,
.order-progress-panel::-webkit-scrollbar-track,
.channel-form-card::-webkit-scrollbar-track,
.page::-webkit-scrollbar-track {
  background: rgba(117, 100, 86, 0.08);
  border-radius: 999px;
}

.message {
  max-width: min(700px, 84%);
  width: fit-content;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
}

.message.assistant {
  align-self: flex-end;
  margin-left: 0;
}

.message-bubble {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: 3px 8px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2b5f9a;
  color: #f8fbff;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 5px 12px rgba(15, 47, 99, 0.12);
}

.message.user .message-bubble { background: #2b5f9a; }
.message.assistant .message-bubble { background: #0f2f63; }
.message img { max-width: min(320px, 100%); border-radius: 14px; display: block; }
.message-time {
  display: block;
  color: #756456;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
}

.message.user .message-time {
  align-self: flex-start;
  text-align: left;
}

.message.assistant .message-time {
  align-self: flex-end;
  text-align: right;
}

.message-bubble-time {
  display: block;
  margin-top: 4px;
  color: rgba(248, 251, 255, 0.88);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.1;
  text-align: right;
}

.composer {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.contacts-list,
.settings-list,
.channel-list,
.assistant-list {
  display: grid;
  gap: 10px;
}

.contact-row,
.settings-row,
.channel-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.66);
}

.contact-row {
  align-items: center;
}

.channel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  height: auto;
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  height: auto;
}

.single-column-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: 100%;
}

.page[data-page="channels"] > .channel-layout,
.page[data-page="whatsappLinks"] > .single-column-page,
.page[data-page="assistants"] > .assistant-layout,
.page[data-page="notifications"] > .assistant-layout,
.page[data-page="notifications"] > .panel-card,
.page[data-page="templates"] .campaign-page,
.page[data-page="flows"] .flows-page {
  width: 100%;
}

.page[data-page="notifications"] > .panel-card {
  margin-top: 16px;
}

.page[data-page="channels"] .form-grid,
.page[data-page="assistants"] .form-grid,
.page[data-page="stores"] .form-grid,
.page[data-page="triggers"] .form-grid,
.page[data-page="settings"] .form-grid,
.page[data-page="notifications"] .form-grid,
.page[data-page="templates"] .form-grid,
.page[data-page="flows"] .form-grid {
  grid-template-columns: minmax(0, 1fr);
}

.channel-form-card {
  overflow: auto;
}

.channel-connect-options {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin: 14px 0;
  border: 1px solid color-mix(in srgb, var(--page-accent) 28%, var(--line));
  border-radius: 14px;
  background: var(--page-accent-soft);
}

.channel-connect-options strong,
.channel-connect-options span {
  display: block;
}

.channel-connect-options span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.channel-connect-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.assistant-editor-card {
  overflow: auto;
}

.settings-top-layout,
.settings-store-layout {
  margin-bottom: 16px;
}

.settings-download {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
}

.assistant-form {
  display: grid;
  gap: 14px;
}

.assistant-form label {
  display: grid;
  gap: 8px;
}

.assistant-item {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.76);
  color: var(--text);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.assistant-item.active {
  border-color: var(--page-accent);
  box-shadow: inset 4px 0 0 var(--page-accent);
  background: var(--page-accent-soft);
}

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

.assistant-preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.channel-form {
  display: grid;
  gap: 14px;
}

.channel-form label {
  display: grid;
  gap: 8px;
}

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

.channel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.external-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-row {
  align-items: flex-start;
}

.channel-row-meta {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.channel-number {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.channel-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.channel-row.active-channel {
  border-color: var(--page-accent);
  box-shadow: inset 0 0 0 1px var(--page-accent-soft);
}

.social-channel-row {
  border-color: rgba(15, 47, 99, 0.18);
  background: rgba(248, 251, 255, 0.78);
}

.social-linked-account {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.contact-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.small {
  font-size: 13px;
}

.placeholder-card {
  min-height: 320px;
  display: grid;
  align-content: start;
}

.download-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.download-meta,
.download-steps {
  display: grid;
  gap: 10px;
}

.inline-guide,
.advanced-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.58);
  padding: 14px 16px;
}

.inline-guide {
  display: grid;
  gap: 8px;
}

.inline-guide p {
  margin: 0;
  color: var(--muted);
}

.advanced-box summary {
  cursor: pointer;
  font-weight: 700;
}

.advanced-box-content {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.empty-inline {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255,255,255,.4);
}

.flows-page {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.flow-toolbar,
.flow-node-actions,
.flow-section-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.flow-section-head {
  justify-content: space-between;
  margin-top: 4px;
}

.flow-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - 170px);
}

.flow-layout.inspector-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.flow-layout.inspector-collapsed .flow-inspector-card {
  display: none;
}

.flow-inspector-card {
  grid-column: auto;
}

.flow-list,
.flow-trigger-list {
  display: grid;
  gap: 10px;
}

.flow-list {
  max-height: 320px;
  overflow: auto;
}

.flow-list-item {
  width: 100%;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 6px;
}

.flow-list-item.active {
  border-color: var(--page-accent);
  background: var(--page-accent-soft);
}

.flow-list-head,
.flow-trigger-preview {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.inline-check {
  display: flex !important;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.inline-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.flow-trigger-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.flow-node-type,
.flow-branch {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flow-builder-stage {
  min-height: calc(100vh - 230px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.flow-builder-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
}

.flow-canvas-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.flow-pan-toggle.active {
  border-color: #1b74e4;
  background: #e8f1ff;
  color: #1057ad;
}

.flow-canvas {
  position: relative;
  min-height: 720px;
  overflow: auto;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(32, 23, 15, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 23, 15, 0.04) 1px, transparent 1px),
    #f5f6f8;
  background-size: 24px 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}

.flow-canvas.pan-active,
.flow-canvas.middle-pan {
  cursor: grab;
}

.flow-canvas.panning {
  cursor: grabbing;
  user-select: none;
}

.flow-canvas.pan-active .flow-block {
  cursor: grab;
}

.flow-canvas-lines,
.flow-canvas-nodes {
  position: absolute;
  inset: 0;
  min-width: 1800px;
  min-height: 1200px;
}

.flow-canvas-lines {
  pointer-events: none;
  z-index: 1;
}

.flow-canvas-lines path {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.flow-canvas-lines text {
  font-size: 11px;
  fill: #667085;
  paint-order: stroke;
  stroke: #f5f6f8;
  stroke-width: 5px;
}

.flow-start-block,
.flow-block {
  position: absolute;
  z-index: 2;
  width: 260px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #d8dee8;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
}

.flow-start-block {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #93b7e8;
}

.flow-start-block span {
  color: #667085;
  font-size: 12px;
  font-weight: 700;
}

.flow-start-link {
  background: #eef6ff;
  color: #1163c7;
  border: 1px dashed #8bc1ff;
  padding: 9px 10px;
  border-radius: 10px;
}

.flow-block {
  cursor: grab;
}

.flow-block.selected {
  border-color: #1b74e4;
  box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.15), 0 16px 34px rgba(16, 24, 40, 0.15);
}

.flow-start-block.connecting-source,
.flow-block.connecting-source {
  border-color: #1b74e4;
  box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.18), 0 16px 34px rgba(16, 24, 40, 0.15);
}

.flow-block.connect-target {
  cursor: crosshair;
}

.flow-block.connect-target:not(.connecting-source):hover {
  border-color: #1b74e4;
  box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.18), 0 16px 34px rgba(16, 24, 40, 0.14);
}

.flow-block-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #edf0f5;
}

.flow-channel-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #1b74e4;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}

.flow-block-head strong,
.flow-block-head small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.flow-block-head small {
  color: #667085;
  font-size: 11px;
}

.flow-block-inline {
  display: grid;
  gap: 8px;
  margin: 12px;
}

.flow-block-inline label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.flow-block-inline label span,
.flow-block-inline-buttons > span {
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-block-inline input,
.flow-block-inline textarea,
.flow-block-inline select {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid #d8dee8;
  background: #f8fafc;
  color: #1f2937;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
}

.flow-block-inline textarea {
  min-height: 72px;
  resize: none;
}

.flow-block-inline input:focus,
.flow-block-inline textarea:focus,
.flow-block-inline select:focus {
  outline: none;
  border-color: #1b74e4;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.12);
}

.flow-block-inline-split,
.flow-block-inline-button-row {
  display: grid;
  gap: 8px;
}

.flow-block-inline-buttons {
  display: grid;
  gap: 7px;
}

.flow-block-inline-button-row {
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #edf0f5;
  background: rgba(248, 251, 255, 0.8);
}

.flow-block-delete {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #98a2b3;
  border: 1px solid transparent;
}

.flow-block-delete:hover {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--danger-soft);
}

.flow-block-body {
  margin: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #f2f4f7;
  color: #344054;
  font-size: 13px;
  line-height: 1.35;
  min-height: 48px;
  overflow-wrap: anywhere;
}

.flow-block-buttons {
  display: grid;
  gap: 6px;
  margin: 0 12px 12px;
}

.flow-block-buttons span {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: #1b74e4;
  background: #f8fbff;
  border: 1px solid #d8e9ff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.flow-block-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid #edf0f5;
  flex-wrap: wrap;
}

.flow-block-footer button {
  padding: 7px 9px;
  border-radius: 999px;
  background: #fff;
  color: #1b74e4;
  border: 1px solid #d8e9ff;
  font-size: 12px;
}

.flow-block-condition {
  border-top: 4px solid #1b74e4;
}

.flow-block-delay {
  border-top: 4px solid #f5b942;
}

.flow-block-assistant {
  border-top: 4px solid #2b5f9a;
}

.flow-block-action {
  border-top: 4px solid #9b72f2;
}

.flow-inspector-card {
  max-height: none;
  overflow: auto;
}

.flow-inspector-toggle {
  align-self: flex-start;
  white-space: nowrap;
}

.flow-inspector-restore {
  border-color: #1b74e4;
  color: #1057ad;
  background: #e8f1ff;
}

.flow-node-inspector,
.flow-inspector-buttons {
  display: grid;
  gap: 10px;
}

.flow-inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.flow-inspector-button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
}

.campaign-page {
  display: grid;
  gap: 16px;
  min-height: 0;
}

.campaign-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.campaign-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.campaign-grid-bottom {
  grid-template-columns: minmax(0, 1fr);
}

.campaign-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.campaign-stack .campaign-saved-list {
  max-height: 340px;
}

.campaign-list-card,
.campaign-builder-card {
  min-height: 0;
}

.campaign-template-list,
.campaign-saved-list,
.campaign-run-result {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}

.campaign-template-item,
.campaign-saved-main {
  width: 100%;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 6px;
}

.campaign-template-item.active,
.campaign-saved-item.active .campaign-saved-main {
  border-color: var(--page-accent);
  background: var(--page-accent-soft);
}

.campaign-template-head,
.campaign-buttons-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.campaign-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.campaign-status.approved {
  color: var(--accent);
  background: var(--accent-soft);
}

.campaign-status.pending {
  color: #8a5b00;
  background: #fff2cc;
}

.campaign-status.rejected {
  color: var(--danger);
  background: var(--danger-soft);
}

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

.campaign-media-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.campaign-button-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(150px, 1fr) minmax(170px, 1fr) minmax(160px, 1fr) minmax(140px, .9fr) auto;
  gap: 8px;
  align-items: center;
}

.campaign-button-row input,
.campaign-button-row select {
  min-width: 0;
}

.campaign-preview-row {
  display: flex;
  justify-content: flex-start;
}

.template-variable-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
}

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

.template-variable-preset {
  width: min(220px, 100%);
  min-height: 38px;
}

.template-variable-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.template-variable-row span {
  font-weight: 800;
  color: var(--page-accent);
}

.campaign-create-panel,
.campaign-audience-panel,
.campaign-cost-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.campaign-audience-head,
.campaign-cost-head,
.campaign-audience-actions,
.campaign-audience-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.campaign-audience-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.campaign-audience-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.campaign-audience-filters,
.campaign-cost-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.campaign-cost-grid {
  grid-template-columns: minmax(160px, 1.1fr) repeat(4, minmax(100px, 1fr));
}

.campaign-cost-grid > div {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
}

.campaign-cost-grid > div span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.campaign-audience-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 2px;
}

.campaign-audience-empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.52);
}

.campaign-audience-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.campaign-audience-item strong,
.campaign-audience-item small,
.campaign-audience-item em {
  display: block;
}

.campaign-audience-item small,
.campaign-audience-item em {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.campaign-audience-item em {
  font-style: normal;
  margin-top: 4px;
}

.campaign-audience-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.campaign-audience-tags b {
  border-radius: 999px;
  background: var(--page-accent-soft);
  color: var(--page-accent-ink);
  font-size: 11px;
  padding: 3px 6px;
}

.wa-preview {
  max-width: 360px;
  width: 100%;
  background: #111;
  padding: 10px;
  border-radius: 24px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}

.wa-preview-top {
  background: #0f2f63;
  color: #fff;
  padding: 8px 12px;
  border-radius: 16px 16px 6px 6px;
  font-size: 12px;
  font-weight: 700;
}

.wa-preview-screen {
  background: #e8f1ff;
  padding: 10px;
  border-radius: 6px 6px 16px 16px;
}

.wa-bubble {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  color: #1d2327;
}

.wa-header-text {
  font-weight: 700;
  margin-bottom: 6px;
}

.wa-header-media img {
  width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}

.wa-media-placeholder {
  background: #f1f3f5;
  color: #666;
  font-size: 12px;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 6px;
}

.wa-body {
  font-size: 13px;
  line-height: 1.45;
}

.wa-footer {
  color: #666;
  margin-top: 8px;
  font-size: 11px;
}

.wa-buttons {
  margin-top: 8px;
  border-top: 1px solid #eee;
}

.wa-button {
  text-align: center;
  color: #1b74e4;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 4px;
}

.wa-button + .wa-button {
  border-top: 1px solid #f0f0f0;
}

.wa-button small {
  display: block;
  color: #666;
  font-size: 10px;
  margin-top: 2px;
  font-weight: 500;
}

.tpl-var {
  background: #ffe9b3;
  border-radius: 4px;
  padding: 0 3px;
}

.campaign-saved-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.campaign-result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.campaign-result-row.ok {
  color: var(--accent);
}

.campaign-result-row.pending {
  color: #9a6700;
}

.campaign-result-row.error {
  color: var(--danger);
}

.campaign-status-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.campaign-status-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.campaign-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.campaign-summary-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.campaign-summary-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.campaign-summary-card span {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.campaign-number-row {
  display: grid;
  grid-template-columns: 1fr .8fr 1fr 1fr .9fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.campaign-summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.campaign-summary-item strong {
  font-size: 24px;
  line-height: 1;
}

.campaign-status-detail {
  min-height: 44px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
}

.campaign-status-detail strong,
.campaign-status-detail em {
  display: block;
}

.campaign-status-detail pre {
  margin: 8px 0 0;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--text);
  font-family: inherit;
}

.campaign-status-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mobile-back-button {
  display: none;
}

@media (max-width: 1080px) {
  .app,
  .app.console-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-radius: 0 0 24px 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    flex: initial;
  }

  .app.is-inbox .workspace,
  .app.chat-list-collapsed .workspace {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .app.chat-list-collapsed .sidebar-card {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .app.chat-list-collapsed .sidebar-head {
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .app.chat-list-collapsed .sidebar-head-title,
  .app.chat-list-collapsed #chat-search,
  .app.chat-list-collapsed .chat-list {
    display: initial;
  }

  .app.chat-list-collapsed .sidebar-head-title {
    display: flex;
  }

  .app.chat-list-collapsed #chat-search {
    display: block;
  }

  .app.chat-list-collapsed .chat-list {
    display: grid;
  }

  .channel-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .assistant-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .flow-layout,
  .flow-layout.inspector-collapsed {
    grid-template-columns: 1fr;
  }

  .flow-inspector-card {
    grid-column: auto;
  }

  .flow-trigger-row {
    grid-template-columns: 1fr;
  }

  .campaign-grid,
  .campaign-grid-bottom {
    grid-template-columns: 1fr;
  }

  .dashboard-hero,
  .dashboard-grid,
  .dashboard-grid-bottom {
    grid-template-columns: 1fr;
  }

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

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

  .dashboard-health-row {
    grid-template-columns: 1fr;
  }

  .campaign-button-row {
    grid-template-columns: 1fr;
  }

  .campaign-audience-filters,
  .campaign-cost-grid,
  .campaign-summary-grid {
    grid-template-columns: 1fr;
  }

  .page,
  .main,
  .app,
  .sidebar {
    height: auto;
    overflow: visible;
  }

  .conversation-card,
  .sidebar-card,
  .empty-state {
    height: auto;
    min-height: 360px;
  }

  .conversation-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(360px, 1fr) auto;
  }

  .order-progress-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 260px;
  }

  .app.is-inbox.order-progress-collapsed .conversation-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(360px, 1fr) 52px;
  }

  .app.order-progress-collapsed .order-progress-panel {
    max-height: 52px;
  }

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

@media (max-width: 768px) {
  .shell,
  .app,
  .main {
    min-height: 100dvh;
    height: 100dvh;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 10px;
    gap: 10px;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .topbar {
    border-radius: 22px;
    padding: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .topbar-actions {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar-actions .pill {
    flex: 0 0 auto;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(14, minmax(82px, 1fr));
    gap: 8px;
    overflow-x: auto;
    min-height: 66px;
    padding-bottom: 4px;
    flex: 0 0 auto;
    scrollbar-gutter: stable;
  }

  .mobile-nav-item {
    position: relative;
    background: rgba(255, 255, 255, 0.82);
    color: var(--text);
    border: 1px solid var(--line);
    padding: 10px 8px;
    border-radius: 18px;
    display: grid;
    gap: 4px;
    justify-items: center;
    font-size: 11px;
    font-weight: 700;
  }

  .mobile-nav-item.active {
    background: var(--page-accent);
    color: #fff;
  }

  .mobile-nav-item.has-unread::after {
    right: 8px;
    top: 7px;
    transform: none;
  }

  .dashboard-stats-grid,
  .dashboard-module-grid,
  .dashboard-campaign-grid {
    grid-template-columns: 1fr;
  }

  .mobile-nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  .page {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .page:not([data-page="inbox"]) {
    padding-bottom: 4px;
  }

  .inbox-filterbar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 8px;
    flex: 0 0 auto;
    min-height: 42px;
    scrollbar-gutter: stable;
  }

  .filter-control {
    flex: 0 0 auto;
    max-width: 220px;
  }

  .inbox-bulk-panel {
    padding: 8px;
    max-height: 360px;
  }

  .inbox-bulk-head,
  .inbox-bulk-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .inbox-bulk-list {
    max-height: 190px;
  }

  .workspace {
    display: block;
    height: auto;
    max-height: none;
  }

  .app.is-inbox .workspace,
  .app.chat-list-collapsed .workspace {
    flex: 0 0 auto;
    height: auto;
    max-height: none;
  }

  .sidebar-card {
    height: max(360px, calc(100dvh - 260px));
    max-height: 620px;
    min-height: 0;
  }

  .conversation {
    display: none;
  }

  .page[data-page="inbox"].mobile-chat-open .sidebar-card {
    display: none;
  }

  .page[data-page="inbox"].mobile-chat-open .conversation {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    position: fixed;
    inset: 0;
    z-index: 50;
    background:
      radial-gradient(circle at top left, rgba(27, 116, 228, 0.12), transparent 28%),
      radial-gradient(circle at bottom right, rgba(197, 147, 88, 0.16), transparent 24%),
      var(--bg);
    padding: 8px;
  }

  .page[data-page="inbox"].mobile-chat-open .conversation-card:not(.hidden),
  .page[data-page="inbox"].mobile-chat-open .empty-state:not(.hidden) {
    display: grid !important;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 24px;
  }

  .page[data-page="inbox"].mobile-chat-open .conversation-card.hidden,
  .page[data-page="inbox"].mobile-chat-open .empty-state.hidden {
    display: none !important;
  }

  .conversation-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .conversation-head-main {
    align-items: flex-start;
  }

  .conversation-head h3 {
    font-size: 24px;
  }

  .mobile-back-button {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .control-row {
    overflow: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .control-row .ghost-button,
  .control-row .danger,
  .control-row .danger-soft {
    white-space: nowrap;
  }

  .message {
    max-width: 92%;
    width: fit-content;
    align-self: flex-start;
  }

  .message.assistant {
    align-self: flex-end;
  }

  .campaign-number-row {
    grid-template-columns: 1fr;
  }

  .conversation-body,
  .app.is-inbox .conversation-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 140px;
  }

  .app.social-inbox .conversation-body,
  .app.social-inbox.order-progress-collapsed .conversation-body {
    grid-template-rows: minmax(0, 1fr);
  }

  .app.is-inbox.order-progress-collapsed .conversation-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 52px;
  }

  .order-progress-panel {
    padding: 10px;
  }

  .order-progress-table {
    border-spacing: 0 6px;
  }

  .order-progress-table td {
    padding: 8px;
  }

  .composer {
    gap: 6px;
    padding: 8px 10px;
  }

  .composer textarea {
    min-height: 62px;
    height: 70px;
  }

  .composer-actions {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .composer-actions .muted {
    display: none;
  }

  .composer-actions button {
    flex: 0 0 auto;
    padding: 10px 14px;
    border-radius: 12px;
  }

  .composer-actions {
    justify-content: space-between;
  }

  .channel-layout {
    grid-template-columns: 1fr;
  }

  .contact-row,
  .channel-row,
  .settings-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .contact-meta,
  .channel-row-actions {
    justify-content: flex-start;
  }
}
