:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ec;
  --blue: #1877f2;
  --blue-dark: #0f5ec7;
  --green: #12b76a;
  --amber: #f79009;
  --shadow: 0 18px 50px rgba(25, 35, 55, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #101828;
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  font-weight: 800;
}

.brand strong,
.connect-card strong {
  display: block;
}

.brand span,
.connect-card p {
  color: #bac3d2;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #d8deea;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.connect-card {
  position: relative;
  margin-top: auto;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
}

.connect-card.connected .status-dot {
  background: var(--green);
}

.facebook-button,
.primary-button,
.small-button,
.ghost-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.facebook-button {
  background: var(--blue);
  color: #ffffff;
}

.facebook-button:hover {
  background: var(--blue-dark);
}

.facebook-button.wide {
  width: 100%;
}

.wide {
  width: 100%;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

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

.primary-button {
  background: #172033;
  color: #ffffff;
}

.ghost-button,
.small-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.permission-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid #c7ddff;
  border-radius: 8px;
  padding: 16px;
  background: #eef6ff;
}

.permission-banner p {
  margin-bottom: 0;
}

.automation-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(360px, 1fr) minmax(260px, 340px);
  gap: 18px;
  align-items: start;
}

.rules-panel,
.builder-panel,
.preview-panel,
.app-view {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.rules-panel,
.builder-panel,
.app-view {
  padding: 18px;
}

.panel-header,
.builder-header,
.reply-toolbar,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header p,
.reply-toolbar p {
  margin-bottom: 0;
  font-size: 13px;
}

.icon-button {
  display: grid;
  min-width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
}

.rule-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.rule-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #ffffff;
  text-align: left;
}

.rule-card.active {
  border-color: var(--blue);
  background: #f0f6ff;
}

.rule-card strong {
  display: block;
  margin-bottom: 4px;
}

.rule-card span {
  color: var(--muted);
  font-size: 13px;
}

.builder-panel {
  display: grid;
  gap: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 160ms ease;
}

.toggle input:checked + span {
  background: var(--green);
}

.toggle input:checked + span::after {
  transform: translateX(20px);
}

.flow-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  padding-top: 22px;
}

.step-badge {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--blue);
  font-weight: 800;
}

.flow-line {
  width: 2px;
  height: 28px;
  margin-left: 16px;
  background: var(--line);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #ffffff;
}

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

.step-content > p {
  margin: 8px 0 0;
  font-size: 13px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #f8fafc;
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: #ffffff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(20, 33, 61, 0.12);
}

.reply-editor {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.reply-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.reply-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.remove-reply {
  border: 0;
  background: transparent;
  color: #d92d20;
  font-weight: 800;
}

.add-reply {
  border: 1px dashed var(--blue);
  border-radius: 8px;
  min-height: 44px;
  background: #f0f6ff;
  color: var(--blue);
  font-weight: 800;
}

.preview-panel {
  padding: 16px;
}

.phone {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #eef2f7;
}

.phone-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.phone-header span {
  display: block;
  color: var(--green);
  font-size: 12px;
}

.chat-window {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 430px;
  padding: 14px;
}

.bubble {
  max-width: 84%;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
}

.bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--blue);
  color: #ffffff;
}

.bubble.bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: #ffffff;
}

.bubble img {
  display: block;
  width: 100%;
  border-radius: 8px;
}

.quick-button {
  align-self: flex-start;
  border: 1px solid #b7d4ff;
  border-radius: 999px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.phone-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 12px;
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  background: #ffffff;
}

.phone-input span {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.phone-input button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
}

.app-view {
  min-height: 420px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.conversation-list {
  display: grid;
  align-content: start;
  gap: 8px;
}

.conversation {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.conversation.active {
  border-color: var(--blue);
  background: #f0f6ff;
}

.conversation span,
.conversation small {
  color: var(--muted);
}

.operator-chat {
  display: flex;
  min-height: 420px;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #eef2f7;
}

.operator-box {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.operator-box textarea {
  min-height: 82px;
}

.customer-sidebar {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.tag {
  background: #eef4ff;
  color: #175cd3;
}

.status.good {
  background: #dcfae6;
  color: #067647;
}

.status.warn {
  background: #fef0c7;
  color: #b54708;
}

.compact {
  justify-content: flex-start;
  margin-top: 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  text-align: left;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.settings-grid,
.developer-grid,
.launch-grid,
.metrics-grid,
.analytics-grid,
.plans-grid,
.admin-grid,
.legal-grid {
  display: grid;
  gap: 16px;
}

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

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

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

.metrics-grid,
.admin-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.analytics-grid,
.campaign-layout,
.legal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.info-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.info-card p {
  margin-bottom: 12px;
  font-size: 14px;
}

.info-card code {
  display: inline-flex;
  max-width: 100%;
  border-radius: 6px;
  padding: 7px 9px;
  background: #f2f4f7;
  color: #344054;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status-list,
.schema-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.schema-grid code {
  flex: 1 1 145px;
}

.setup-card {
  border-color: #b7d4ff;
  background: #f0f6ff;
}

.setup-code {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.config-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #ffffff;
}

.config-status p {
  margin: 8px 0 0;
  font-size: 13px;
}

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

.checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #344054;
  font-size: 14px;
  line-height: 1.35;
}

.checklist input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--blue);
}

.composer-panel,
.campaign-preview,
.metric-card,
.plan-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.composer-panel {
  display: grid;
  gap: 12px;
}

.campaign-preview {
  display: grid;
  align-content: start;
  gap: 12px;
  background: #eef2f7;
}

.warning-box {
  border: 1px solid #fedf89;
  border-radius: 8px;
  padding: 12px;
  background: #fffaeb;
  color: #93370d;
  font-size: 13px;
  font-weight: 700;
}

.metric-card {
  display: grid;
  gap: 6px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  font-size: 30px;
  letter-spacing: 0;
}

.metric-card small {
  color: var(--green);
  font-weight: 700;
}

.bar-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 50px;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.bar-row div {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #eef2f7;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.plan-card {
  display: grid;
  gap: 12px;
}

.plan-card.featured {
  border-color: var(--blue);
  background: #f0f6ff;
}

.plan-card strong {
  font-size: 28px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.56);
}

.modal {
  width: min(520px, 100%);
  border-radius: 8px;
  padding: 20px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.permission-flow {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.permission-step {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-weight: 800;
}

.permission-step.active {
  border-color: var(--blue);
  background: #eef6ff;
}

.permission-step span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #e8eef7;
}

.permission-step.done span {
  background: #dcfae6;
  color: #067647;
}

.permission-box {
  margin-bottom: 18px;
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.permission-box ul {
  margin-bottom: 0;
  padding-left: 20px;
  color: var(--muted);
}

.connect-modal {
  width: min(640px, 100%);
}

.connect-step {
  display: grid;
  gap: 14px;
}

.facebook-login-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid #c7ddff;
  border-radius: 8px;
  padding: 14px;
  background: #eef6ff;
}

.facebook-logo {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
}

.page-picker {
  display: grid;
  gap: 10px;
}

.page-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #ffffff;
}

.page-option.selected {
  border-color: var(--blue);
  background: #f0f6ff;
}

.page-option input,
.permission-checks input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.page-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.permission-checks {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcff;
}

.permission-checks label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: #344054;
}

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

.redirect-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
}

.redirect-note code {
  display: inline-block;
  margin-top: 4px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.success-state {
  text-align: center;
}

.success-icon {
  display: grid;
  width: 60px;
  height: 60px;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #dcfae6;
  color: #067647;
  font-size: 30px;
  font-weight: 800;
}

.connection-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #172033;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .automation-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
  }

  .settings-grid,
  .launch-grid,
  .metrics-grid,
  .plans-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inbox-grid {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .customer-sidebar {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .permission-banner,
  .panel-header,
  .builder-header,
  .reply-toolbar,
  .view-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

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

  .segmented {
    width: 100%;
  }

  .inbox-grid,
  .settings-grid,
  .developer-grid,
  .launch-grid,
  .metrics-grid,
  .analytics-grid,
  .plans-grid,
  .admin-grid,
  .legal-grid,
  .campaign-layout,
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

/* Comment Reply Styling */
.posts-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
}

.posts-list {
  display: grid;
  gap: 10px;
  max-height: 600px;
  overflow-y: auto;
}

.post-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
}

.post-card:hover {
  border-color: var(--blue);
  background: #f0f6ff;
}

.post-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.post-header small {
  color: var(--muted);
}

.post-content {
  margin-bottom: 8px;
  line-height: 1.4;
  font-size: 14px;
}

.comments-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.comment-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

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

.comment-header h3 {
  margin: 0;
  font-size: 16px;
}

.comments-view {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  max-height: 300px;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcff;
}

.comment-author {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.comment-text {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 6px;
}

.comment-item small {
  color: var(--muted);
  font-size: 11px;
}

.reply-button {
  display: block;
  margin-top: 6px;
  padding: 4px 10px;
  border: none;
  border-radius: 4px;
  background: var(--blue);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
}

.reply-button:hover {
  background: var(--blue-dark);
}

.comment-reply-box {
  display: grid;
  gap: 8px;
}

.comment-reply-box textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-height: 80px;
  font-size: 13px;
  resize: none;
}

@media (max-width: 820px) {
  .posts-layout {
    grid-template-columns: 1fr;
  }
}
