:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --border: #dce1e6;
  --border-strong: #c9d0d7;
  --text: #18212b;
  --text-muted: #66717e;
  --primary: #176b52;
  --primary-hover: #10563f;
  --primary-soft: #e8f4ef;
  --blue: #2864c7;
  --blue-soft: #edf3fd;
  --orange: #a65414;
  --orange-soft: #fff4e9;
  --danger: #b42318;
  --danger-soft: #fef0ee;
  --shadow: 0 8px 30px rgba(24, 33, 43, 0.08);
  --sidebar-width: 248px;
  font-family: Inter, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { min-width: 320px; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
code, pre { font-family: "Cascadia Code", Consolas, monospace; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid #28323d;
  background: #18212b;
  color: #f7f9fa;
}

.brand {
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #2f8b6b;
  color: white;
}
.brand-mark svg { width: 20px; height: 20px; }
.brand div { min-width: 0; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; line-height: 20px; }
.brand div > span { color: #aab4be; font-size: 11px; line-height: 18px; }

.nav { display: grid; gap: 4px; padding: 18px 12px; }
.nav-item {
  display: flex;
  width: 100%;
  height: 42px;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: #b8c1ca;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: #2b3742; color: #fff; }
.nav-item svg { width: 18px; height: 18px; }

.setup-progress {
  margin: auto 16px 14px;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}
.section-label {
  margin-bottom: 11px;
  color: #8995a1;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.progress-row {
  display: flex;
  min-height: 29px;
  align-items: center;
  justify-content: space-between;
  color: #ccd3da;
  font-size: 11px;
}
.progress-row > span:first-child { display: flex; align-items: center; gap: 7px; }
.status-label { color: #8995a1; }
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8c969f;
}
.status-dot.ready { background: #54c894; box-shadow: 0 0 0 3px rgba(84, 200, 148, 0.12); }
.status-dot.error { background: #e45b50; }

.docs-link {
  display: flex;
  height: 45px;
  align-items: center;
  gap: 9px;
  margin: 0 12px 14px;
  border-radius: 6px;
  padding: 0 12px;
  color: #aab4be;
  font-size: 11px;
  text-decoration: none;
}
.docs-link:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.docs-link svg { width: 16px; }
.docs-link svg:last-child { width: 13px; margin-left: auto; }

.main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 13px clamp(20px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.96);
}
.topbar h1 { margin: 0; font-size: 19px; line-height: 26px; }
.topbar p { margin: 1px 0 0; color: var(--text-muted); font-size: 11px; line-height: 17px; }
.api-health {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
}
.api-health.ready .status-dot { background: var(--primary); }
.api-health.live { box-shadow: inset 0 0 0 1px rgba(23, 107, 82, 0.18); }
.api-health.error .status-dot { background: var(--danger); }
.mobile-menu { display: none !important; }

.content { width: min(1240px, 100%); margin: 0 auto; padding: 28px clamp(20px, 4vw, 48px) 64px; }
.view { display: none; }
.view.active { display: block; }

.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 28px;
  border: 1px solid #edc998;
  border-radius: 7px;
  padding: 13px 15px;
  background: var(--orange-soft);
  color: #713a12;
}
.notice > svg { width: 18px; height: 18px; margin-top: 1px; }
.notice strong, .notice span { display: block; }
.notice strong { font-size: 12px; }
.notice span { margin-top: 3px; color: #875022; font-size: 11px; line-height: 17px; }
.notice.error {
  margin-top: 0;
  border-color: #f0b3ad;
  background: var(--danger-soft);
  color: #7a271a;
}
.notice.error span { color: #8a3427; }
.notice.error .result-box {
  margin-top: 10px;
  border-color: #efc2bc;
  background: #fff8f7;
  color: #7a271a;
}
.section-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
h2 { margin: 0; font-size: 16px; line-height: 23px; }
.section-heading p, .panel-heading p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; line-height: 17px; }
.divider { height: 1px; margin: 30px 0; background: var(--border); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.field { min-width: 0; }
.field label, .field-label {
  display: block;
  margin-bottom: 7px;
  color: #35414d;
  font-size: 11px;
  font-weight: 600;
}
.field input, .field select, .field textarea, .toolbar select {
  display: block;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  outline: 0;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  transition: border-color 120ms, box-shadow 120ms;
}
.field textarea { resize: vertical; line-height: 19px; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.1);
}
.field input::placeholder, .field textarea::placeholder { color: #9ca5ae; }
.field > p, .secret-state {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 16px;
}
.secret-state.configured { color: var(--primary); }
.secret-state.configured::before { content: "●"; margin-right: 5px; font-size: 7px; }
.input-action { position: relative; }
.input-action input { padding-right: 42px; }
.input-action .icon-button { position: absolute; top: 3px; right: 3px; }

.guide {
  border-left: 3px solid #80a7e8;
  border-radius: 0 6px 6px 0;
  padding: 11px 14px;
  background: var(--blue-soft);
}
.guide.wide { grid-column: 1 / -1; }
.guide .field-label { margin-bottom: 6px; color: #234e91; }
.guide a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #2559ad;
  font-size: 10px;
  line-height: 17px;
  text-decoration: none;
}
.guide a + a { margin-top: 3px; }
.guide a:hover span { text-decoration: underline; }
.guide a svg { width: 13px; height: 13px; flex: 0 0 auto; }
.guide p { margin: 5px 0 0; color: #51709d; font-size: 10px; line-height: 16px; }
.toggle-field {
  display: flex;
  min-height: 67px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px 13px;
  background: var(--surface);
}
.toggle-field .field-label { margin-bottom: 2px; }
.toggle-field p { margin: 0; }
.switch { margin: 0 !important; }
.switch input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.switch-track {
  position: relative;
  display: block;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #aab2ba;
  transition: background 150ms;
}
.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  content: "";
  transition: transform 150ms;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 13px;
  font-size: 11px;
  font-weight: 600;
}
.button svg { width: 15px; height: 15px; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { border-color: var(--border-strong); background: white; color: #35414d; }
.button.secondary:hover { border-color: #9ca6b0; background: var(--surface-muted); }
.button:disabled { cursor: wait; opacity: 0.6; }
.button.full { width: 100%; }
.button.compact {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 10px;
}
.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
}
.icon-button:hover { background: #edf0f2; color: var(--text); }
.icon-button svg { width: 16px; height: 16px; }

.sticky-actions {
  position: sticky;
  bottom: 14px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}
.save-state { margin-right: auto; padding-left: 4px; color: var(--text-muted); font-size: 10px; }

.toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}
.toolbar select { width: auto; min-width: 160px; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px;
  background: white;
}
.segmented button {
  height: 30px;
  border: 0;
  border-radius: 4px;
  padding: 0 11px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}
.segmented button.active { background: #e9edef; color: var(--text); }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr); gap: 18px; align-items: start; }
.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
}
.panel-heading {
  display: flex;
  min-height: 42px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 13px;
}
.compose-panel { display: grid; gap: 14px; }
.compose-panel .panel-heading { margin-bottom: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table { min-width: 640px; }
.messages-table { min-width: 980px; }
.audit-table { min-width: 860px; }
.access-table { min-width: 640px; }
th {
  border-bottom: 1px solid var(--border);
  padding: 9px 8px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  text-align: left;
  text-transform: uppercase;
}
td {
  overflow: hidden;
  border-bottom: 1px solid #edf0f2;
  padding: 11px 8px;
  color: #35414d;
  font-size: 10px;
  line-height: 16px;
  text-overflow: ellipsis;
  vertical-align: top;
}
th:nth-child(1) { width: 90px; }
th:nth-child(2) { width: 200px; }
th:nth-child(4) { width: 150px; }
th:nth-child(5) { width: 130px; }
th:nth-child(6) { width: 115px; }
th:nth-child(7) { width: 100px; }
.table-actions { display: flex; align-items: center; gap: 3px; }
.table-actions .icon-button { width: 30px; height: 30px; }
.icon-button.danger { color: var(--danger); }
.icon-button:disabled { cursor: not-allowed; opacity: .45; }
.access-status { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 10px; font-weight: 700; }
.access-status.active { background: var(--primary-soft); color: var(--primary); }
.access-status.inactive { background: var(--danger-soft); color: var(--danger); }
.access-form-actions { display: grid; gap: 8px; }
.channel-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  padding: 3px 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 9px;
  font-weight: 600;
  text-transform: capitalize;
}
.channel-badge.facebook { background: #edf1fb; color: #3156a5; }
.contact-summary {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
}
.contact-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #dfe9e5;
  color: #175843;
  font-size: 10px;
  font-weight: 700;
}
.contact-summary-text {
  min-width: 0;
}
.contact-summary-text strong,
.contact-summary-text span {
  display: block;
}
.contact-summary-text strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-summary-text span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.window-chip {
  display: grid;
  gap: 2px;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 9px;
}
.window-chip strong {
  font-size: 9px;
}
.window-chip span {
  color: inherit;
}
.window-chip.open {
  background: #e8f4ef;
  color: #165641;
}
.window-chip.closed {
  background: #fff1ef;
  color: #8a3427;
}
.message-automation-status {
  display: inline-flex;
  min-width: 94px;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  padding: 6px 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
}
.message-automation-status svg { width: 12px; height: 12px; }
.message-automation-status.none { background: #f1f3f4; color: #89939b; font-weight: 500; }
.message-automation-status.waiting_input, .message-automation-status.delayed { background: var(--orange-soft); color: var(--orange); }
.message-automation-status.failed { background: var(--danger-soft); color: var(--danger); }
.message-automation-status.running svg { animation: spin 1s linear infinite; }
.message-automation-status.none { flex-wrap: wrap; }
.message-automation-run {
  width: 100%;
  border: 0;
  border-top: 1px solid #dfe3e5;
  padding: 4px 0 0;
  background: transparent;
  color: var(--primary);
  font-size: 7px;
  font-weight: 700;
  text-align: left;
}
.message-automation-run:hover { text-decoration: underline; }
.sync-feedback {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-left: 4px solid #75838c;
  border-radius: 7px;
  padding: 11px 13px;
  background: white;
}
.sync-feedback > svg { width: 17px; height: 17px; margin-top: 1px; color: #687780; }
.sync-feedback div { display: grid; gap: 2px; }
.sync-feedback strong { font-size: 10px; }
.sync-feedback span { color: var(--text-muted); font-size: 9px; line-height: 14px; }
.sync-feedback.success { border-left-color: var(--primary); background: #f7fbf9; }
.sync-feedback.success > svg { color: var(--primary); }
.sync-feedback.warning { border-left-color: var(--orange); background: #fffaf5; }
.sync-feedback.warning > svg { color: var(--orange); }
.message-reply-context {
  display: grid;
  gap: 4px;
  border: 1px solid #cfe3da;
  border-radius: 7px;
  padding: 10px 12px;
  background: #f3faf7;
  color: #1d5d47;
  font-size: 10px;
}
.message-reply-context span {
  color: #416b5a;
}
.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #909aa4;
  font-size: 11px;
}
.empty-state svg { width: 28px; height: 28px; }
.result-box, .console {
  overflow: auto;
  max-height: 280px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 11px;
  background: #f4f6f8;
  color: #34404c;
  font-size: 10px;
  line-height: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}
.console { min-height: 300px; background: #17212b; color: #d4e0e9; }

.comment-list { display: grid; gap: 0; }
.comment-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 9px 16px;
  border-bottom: 1px solid #edf0f2;
  padding: 12px 2px;
}
.comment-item:first-child { padding-top: 2px; }
.comment-identity { display: grid; min-width: 0; justify-items: start; gap: 3px; }
.comment-item strong { font-size: 11px; }
.comment-item p { grid-column: 2 / -1; margin: 0; color: #35414d; font-size: 11px; line-height: 17px; }
.comment-meta { display: flex; flex-wrap: wrap; gap: 6px 13px; color: var(--text-muted); font-size: 9px; }
.comment-item .button { grid-row: 1 / span 2; grid-column: 3; align-self: center; }
.comment-automation-status {
  border-radius: 999px;
  padding: 3px 7px;
  background: #edf1f2;
  color: #65727b;
  font-size: 8px;
  font-weight: 700;
}
.comment-automation-status.completed { background: var(--primary-soft); color: var(--primary); }
.comment-automation-status.waiting_input,
.comment-automation-status.delayed,
.comment-automation-status.running { background: #eef4fb; color: #356386; }
.comment-automation-status.failed,
.comment-automation-status.cancelled { background: #fff0ed; color: #a84334; }

.webhook-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border-left: 4px solid var(--primary);
  padding: 16px 18px;
  background: var(--primary-soft);
}
.callback-value { display: flex; align-items: center; gap: 8px; }
.callback-value code { overflow-wrap: anywhere; color: #174d3d; font-size: 12px; }
.setup-steps { margin-top: 22px; }
.setup-steps ol { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.setup-steps li {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  border-top: 2px solid var(--border);
  padding-top: 12px;
}
.setup-steps li > span {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #35414d;
  color: white;
  font-size: 9px;
  font-weight: 700;
}
.setup-steps strong { display: block; font-size: 10px; line-height: 16px; }
.setup-steps p, .setup-steps code { display: block; margin: 3px 0 0; color: var(--text-muted); font-size: 9px; line-height: 15px; overflow-wrap: anywhere; }
.setup-steps li > div > code { display: block; }
.setup-steps p code {
  display: inline;
  margin: 0;
  padding: 1px 3px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.webhook-events-panel { margin-top: 24px; }
.webhook-event-list { display: grid; gap: 0; }
.webhook-event {
  display: grid;
  grid-template-columns: minmax(190px, 0.4fr) minmax(0, 1fr);
  gap: 16px;
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.webhook-event-summary { display: grid; align-content: start; gap: 5px; }
.webhook-event-summary strong { font-size: 11px; }
.webhook-event-summary span { color: var(--text-muted); font-size: 9px; line-height: 15px; }
.webhook-event .console { min-height: 130px; max-height: 260px; }

/* Automation builder */
.content.automation-content {
  width: 100%;
  max-width: none;
  padding: 18px 22px 28px;
}
.automation-topbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px 9px 16px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(24, 33, 43, 0.05);
}
.automation-title-block { display: grid; gap: 2px; min-width: 0; }
.automation-title-status { display: flex; align-items: center; gap: 7px; }
.automation-title-block strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.automation-title-block > span:last-child { color: var(--text-muted); font-size: 9px; }
.automation-kicker { color: var(--primary) !important; font-size: 8px !important; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.automation-publication-badge {
  border-radius: 9px;
  padding: 3px 7px;
  font-size: 7px !important;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.automation-publication-badge.active { background: var(--primary-soft); color: var(--primary) !important; }
.automation-publication-badge.draft { background: #edf0f2; color: #6f7b84 !important; }
.automation-publication-badge.dirty { background: var(--orange-soft); color: var(--orange) !important; }
.automation-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.automation-topbar-delete { border-color: #e1aaa5 !important; color: var(--danger) !important; }
.automation-builder {
  display: grid;
  grid-template-columns: 238px minmax(480px, 1fr) 286px;
  height: calc(100vh - 182px);
  min-height: 610px;
  overflow: hidden;
  border: 1px solid #cfd6dc;
  border-radius: 10px;
  background: #eef1f2;
  box-shadow: 0 12px 38px rgba(24, 33, 43, 0.1);
}
.automation-library, .automation-inspector {
  position: relative;
  z-index: 4;
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #fbfcfc;
}
.automation-library { border-right: 1px solid var(--border); }
.automation-inspector { border-left: 1px solid var(--border); }
.automation-pane-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 10px 15px;
  background: white;
}
.automation-pane-heading div { display: grid; gap: 2px; }
.automation-pane-heading span { color: #2f3b46; font-size: 11px; font-weight: 700; }
.automation-pane-heading small { color: var(--text-muted); font-size: 8px; }
.automation-flow-list { display: grid; max-height: 244px; overflow: auto; padding: 8px; }
.automation-flow-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.automation-flow-item:hover { background: #f0f3f3; }
.automation-flow-item.active { border-color: #acd2c4; background: var(--primary-soft); }
.automation-flow-item strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.automation-flow-item small { grid-column: 1; color: var(--text-muted); font-size: 8px; }
.automation-flow-status { align-self: start; border-radius: 9px; padding: 3px 6px; background: #edf0f2; color: #78838b; font-size: 7px; font-weight: 700; }
.automation-flow-status.active { background: var(--primary-soft); color: var(--primary); }
.automation-empty {
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 24px 15px;
  color: #8a959e;
  font-size: 9px;
  text-align: center;
}
.automation-empty svg { width: 23px; height: 23px; }
.automation-palette { margin-top: auto; border-top: 1px solid var(--border); padding: 13px; background: white; }
.automation-pane-label { display: block; margin-bottom: 9px; color: #78838d; font-size: 8px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.automation-palette-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.automation-palette-grid button {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 4px;
  background: #fafbfb;
  color: #46525e;
  font-size: 8px;
  font-weight: 600;
}
.automation-palette-grid button:hover { border-color: #91beae; background: var(--primary-soft); color: var(--primary); transform: translateY(-1px); }
.automation-palette-grid button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }
.automation-palette-grid svg { width: 16px; height: 16px; }
.automation-canvas-panel { position: relative; min-width: 0; overflow: hidden; background: #dfe4e5; }
.automation-canvas-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(195, 204, 210, 0.9);
  border-radius: 7px;
  padding: 3px 6px 3px 11px;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 5px 18px rgba(34, 45, 53, 0.08);
  color: #6c7882;
  font-size: 8px;
  backdrop-filter: blur(7px);
}
.automation-canvas-toolbar > span { display: flex; align-items: center; gap: 6px; }
.automation-canvas-toolbar svg { width: 13px; height: 13px; }
.automation-library-toggle { display: none; }
.automation-canvas-viewport {
  width: 100%;
  height: 100%;
  overflow: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.automation-canvas-viewport.is-panning { cursor: grabbing; }
.automation-canvas {
  position: relative;
  width: 1400px;
  height: 900px;
  background-color: #e9edee;
  background-image: radial-gradient(circle, #bdc6ca 1px, transparent 1px);
  background-size: 22px 22px;
}
.automation-edges, .automation-nodes { position: absolute; inset: 0; width: 100%; height: 100%; }
.automation-edges { z-index: 1; overflow: visible; }
.automation-edges marker path { fill: #6f817b; }
.automation-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.automation-edge-line { fill: none; stroke: #7d9089; stroke-width: 2; marker-end: url(#automation-arrow); pointer-events: none; }
.automation-edge-line.selected { stroke: #d07932; stroke-width: 3; }
.automation-nodes { z-index: 2; pointer-events: none; }
.automation-node {
  position: absolute;
  width: 194px;
  min-height: 88px;
  border: 1px solid #c3cdd1;
  border-top: 3px solid var(--node-color, #607884);
  border-radius: 8px;
  background: white;
  box-shadow: 0 7px 20px rgba(32, 44, 52, 0.12);
  pointer-events: auto;
  user-select: none;
}
.automation-node:hover { box-shadow: 0 9px 25px rgba(32, 44, 52, 0.17); }
.automation-node.selected { border-color: var(--node-color, var(--primary)); box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.13), 0 9px 25px rgba(32, 44, 52, 0.14); }
.automation-node.connecting { box-shadow: 0 0 0 3px rgba(208, 121, 50, 0.18), 0 9px 25px rgba(32, 44, 52, 0.14); }
.automation-node-header { display: flex; align-items: center; gap: 7px; padding: 9px 10px 7px; cursor: grab; }
.automation-node-header:active { cursor: grabbing; }
.automation-node-icon { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border-radius: 6px; background: color-mix(in srgb, var(--node-color) 12%, white); color: var(--node-color); }
.automation-node-icon svg { width: 13px; height: 13px; }
.automation-node-header strong { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.automation-node-summary { min-height: 32px; border-top: 1px solid #edf0f1; padding: 7px 10px 9px; color: #6e7982; font-size: 8px; line-height: 13px; }
.automation-port {
  position: absolute;
  z-index: 4;
  width: 13px;
  height: 13px;
  border: 2px solid white;
  border-radius: 50%;
  padding: 0;
  background: #778b83;
  box-shadow: 0 0 0 1px #778b83;
}
.automation-port:hover, .automation-port.pending { background: #df7e32; box-shadow: 0 0 0 2px rgba(223, 126, 50, 0.25); transform: scale(1.15); }
.automation-port.input { top: 50%; left: -7px; transform: translateY(-50%); }
.automation-port.input:hover { transform: translateY(-50%) scale(1.15); }
.automation-port.output { top: 50%; right: -7px; transform: translateY(-50%); }
.automation-port.output:hover { transform: translateY(-50%) scale(1.15); }
.automation-port.output.branch-main { top: 38%; }
.automation-port.output.branch-guardrail { top: 72%; background: #b42318; box-shadow: 0 0 0 1px #b42318; }
.automation-port.output.branch-true { top: 38%; }
.automation-port.output.branch-false { top: 72%; }
.automation-branch-label { position: absolute; right: 9px; color: #7a858e; font-size: 7px; font-weight: 700; }
.automation-branch-label.true { top: 31%; color: var(--primary); }
.automation-branch-label.false { top: 66%; color: var(--orange); }
.automation-branch-label.guardrail { top: 66%; color: #b42318; }
.automation-port.output.branch-ai { background: #7650a8; box-shadow: 0 0 0 1px #7650a8; }
.automation-ai-branch-label { position: absolute; right: 12px; max-width: 145px; overflow: hidden; transform: translateY(-50%); color: #694596; font-size: 7px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.automation-ai-node .automation-node-summary { max-width: 165px; }
.automation-canvas-placeholder { position: absolute; inset: 0; display: grid; place-content: center; place-items: center; gap: 8px; color: #839097; text-align: center; }
.automation-canvas-placeholder svg { width: 34px; height: 34px; }
.automation-canvas-placeholder strong { color: #65727a; font-size: 11px; }
.automation-canvas-placeholder span { font-size: 9px; }
.automation-inspector-content { overflow: auto; padding: 14px; }
.automation-inspector-empty { display: grid; place-items: center; gap: 8px; padding: 50px 15px; color: #8a949d; font-size: 9px; text-align: center; }
.automation-inspector-empty svg { width: 25px; }
.automation-property-group { margin-bottom: 18px; }
.automation-property-group h3 { margin: 0 0 10px; color: #68747e; font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; }
.automation-property-group .field + .field { margin-top: 11px; }
.automation-property-group .field input, .automation-property-group .field select, .automation-property-group .field textarea { min-height: 36px; font-size: 10px; }
.automation-property-group .field textarea { resize: vertical; }
.automation-help { margin: 7px 0 0; color: #7d8992; font-size: 8px; line-height: 13px; }
.automation-property-preview {
  display: grid;
  gap: 3px;
  margin: 8px 0;
  border: 1px solid #d8e3de;
  border-radius: 8px;
  padding: 9px 10px;
  background: #f6faf8;
  color: var(--text);
  font-size: 9px;
  line-height: 13px;
}
.automation-property-preview strong { font-size: 10px; line-height: 14px; }
.automation-property-preview span { color: #305f4c; font-weight: 700; }
.automation-property-preview small { color: var(--text-muted); font-size: 8px; line-height: 12px; }
.automation-property-preview.muted { border-color: var(--border); background: #fafbfb; color: var(--text-muted); }
.automation-publication-picker { display: grid; gap: 8px; margin-top: 11px; }
.automation-publication-selected-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 1px solid #c9ddd6;
  border-radius: 8px;
  padding: 8px;
  background: #f4faf7;
}
.automation-publication-selected-card.all { border-color: #d8dee2; background: #f8fafb; }
.automation-publication-selected-card div,
.automation-publication-option span { display: grid; min-width: 0; gap: 3px; }
.automation-publication-selected-card span:not(.automation-publication-thumb) {
  color: #37715f;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.automation-publication-selected-card strong,
.automation-publication-option strong {
  overflow: hidden;
  color: #2f3c43;
  font-size: 9px;
  line-height: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.automation-publication-selected-card small,
.automation-publication-option small {
  overflow: hidden;
  color: #6f7e86;
  font-size: 7px;
  line-height: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.automation-publication-list {
  display: grid;
  max-height: 230px;
  overflow: auto;
  gap: 6px;
  padding-right: 2px;
}
.automation-publication-option {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid #dde5e2;
  border-radius: 8px;
  padding: 7px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.automation-publication-option:hover { border-color: #a9c8bc; background: #f4faf7; }
.automation-publication-option.selected { border-color: #75ab98; background: #eaf6f1; box-shadow: inset 3px 0 var(--primary); }
.automation-publication-option em {
  overflow: hidden;
  color: #87939a;
  font-size: 7px;
  font-style: normal;
  line-height: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.automation-publication-thumb {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #e8ecee;
  color: #66737b;
}
.automation-publication-selected-card .automation-publication-thumb { width: 52px; height: 52px; }
.automation-publication-thumb img { width: 100%; height: 100%; object-fit: cover; }
.automation-publication-thumb svg { width: 17px; height: 17px; }
.automation-check-field { display: flex; align-items: flex-start; gap: 9px; margin-top: 11px; border: 1px solid #cfe0d8; border-radius: 8px; padding: 10px; background: #f2f8f5; cursor: pointer; }
.automation-check-field input { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--primary); }
.automation-check-field span { display: grid; gap: 3px; }
.automation-check-field strong { color: #315d4b; font-size: 8px; }
.automation-check-field small { color: #718078; font-size: 7px; line-height: 11px; }
.automation-ai-intent-options { display: grid; gap: 6px; }
.automation-ai-intent-option { display: flex; align-items: flex-start; gap: 8px; border: 1px solid #ded2e9; border-radius: 8px; padding: 9px; background: #faf7fd; cursor: pointer; }
.automation-ai-intent-option.inactive { border-style: dashed; opacity: 0.65; cursor: not-allowed; }
.automation-ai-intent-option input { width: 14px; height: 14px; flex: 0 0 auto; accent-color: #7650a8; }
.automation-ai-intent-option span { display: grid; min-width: 0; gap: 2px; }
.automation-ai-intent-option strong { color: #5f3c82; font-size: 8px; }
.automation-ai-intent-option small { color: #7f718c; font-size: 7px; line-height: 11px; }
.automation-danger { width: 100%; border-color: #e1aaa5 !important; color: var(--danger) !important; }
.automation-connection-card { border: 1px solid #ead0b5; border-radius: 7px; padding: 11px; background: #fff8f0; color: #7b4a20; font-size: 9px; line-height: 14px; }
.automation-asset-box { display: grid; gap: 8px; border: 1px solid var(--border); border-radius: 7px; padding: 10px; background: #f7f9f9; }
.automation-asset-box img, .automation-asset-box video { width: 100%; max-height: 130px; border-radius: 5px; object-fit: cover; background: #e6eaeb; }
.automation-asset-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.automation-upload-label { cursor: pointer; }
.automation-upload-label input { display: none; }
.automation-run-list { display: grid; max-height: min(560px, 65vh); overflow: auto; gap: 8px; margin: 16px 0; text-align: left; }
.automation-runs-dialog { width: min(760px, 100%); text-align: left; }
.automation-runs-heading { display: flex; align-items: center; gap: 13px; }
.automation-runs-heading .modal-icon { margin: 0; flex: 0 0 auto; }
.automation-runs-heading h2 { margin: 0; }
.automation-runs-heading p { margin: 3px 0 0; color: var(--text-muted); font-size: 9px; }
.automation-test-dialog { width: min(560px, 100%); text-align: left; }
.automation-test-dialog > .modal-icon { margin-left: 0; }
.modal.automation-test-dialog > h2, .modal.automation-test-dialog > p { text-align: left; }
.automation-test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.automation-test-grid .full { grid-column: 1 / -1; }
.automation-test-result { display: grid; gap: 3px; margin-bottom: 14px; border-radius: 7px; padding: 10px 12px; }
.automation-test-result.success { background: var(--primary-soft); color: var(--primary); }
.automation-test-result.error { background: var(--danger-soft); color: var(--danger); }
.automation-test-result strong { font-size: 10px; }
.automation-test-result span { font-size: 9px; line-height: 14px; }
.automation-test-actions { display: flex; justify-content: flex-end; gap: 7px; }
.automation-run-item { border: 1px solid var(--border); border-radius: 7px; padding: 11px 12px; background: #fbfcfc; }
.automation-run-summary { display: flex; align-items: center; gap: 8px; }
.automation-run-summary strong { font-size: 10px; }
.automation-run-summary time { margin-left: auto; color: var(--text-muted); font-size: 8px; }
.automation-run-item p { margin: 7px 0 0; color: var(--text-muted); font-size: 8px; line-height: 14px; }
.automation-run-logs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.automation-run-logs span { border-radius: 10px; padding: 3px 6px; background: #edf0f1; color: #69757e; font-size: 7px; }
.automation-status-pill { border-radius: 10px; padding: 3px 7px; background: #e9edef; color: #596670; font-size: 7px; font-weight: 700; text-transform: uppercase; }
.automation-status-pill.completed { background: var(--primary-soft); color: var(--primary); }
.automation-status-pill.failed { background: var(--danger-soft); color: var(--danger); }
.automation-status-pill.waiting_input, .automation-status-pill.delayed { background: var(--orange-soft); color: var(--orange); }

.content.chat-content { width: 100%; max-width: 1600px; padding: 18px clamp(14px, 2vw, 28px); }
.chat-toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; border: 1px solid #e0e6e3; border-radius: 13px; padding: 9px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 5px 20px rgba(35, 52, 44, 0.05); }
.chat-toolbar select { min-height: 40px; border-color: #d8e1dc; background-color: #f8faf9; }
#chat-channel-filter { width: 195px; }
#chat-status-filter { width: 175px; }
.chat-search { position: relative; min-width: 220px; flex: 1; }
.chat-search svg { position: absolute; top: 50%; left: 12px; width: 15px; color: #7c8991; transform: translateY(-50%); pointer-events: none; }
.chat-search input { width: 100%; min-height: 40px; border-color: #d8e1dc; padding-left: 38px; background: #f8faf9; }
.chat-workspace { display: grid; grid-template-columns: minmax(230px, 0.78fr) minmax(360px, 1.65fr) minmax(230px, 0.75fr); height: calc(100dvh - 188px); min-height: 540px; overflow: hidden; border: 1px solid #d9e1dd; border-radius: 16px; background: white; box-shadow: 0 18px 50px rgba(27, 47, 37, 0.1); }
.chat-list-panel, .chat-context-panel { min-width: 0; min-height: 0; background: #f8faf9; }
.chat-list-panel { display: flex; overflow: hidden; flex-direction: column; border-right: 1px solid var(--border); }
.chat-pane-heading { display: flex; min-height: 72px; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); padding: 13px 15px; background: rgba(255, 255, 255, 0.96); }
.chat-pane-heading > div { display: grid; gap: 3px; }
.chat-pane-heading strong { font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 600; }
.chat-pane-heading span { color: var(--text-muted); font-size: 10px; }
.chat-live-indicator { display: inline-flex !important; align-items: center; gap: 4px; border-radius: 12px; padding: 4px 7px; background: var(--primary-soft); color: var(--primary) !important; font-weight: 700; text-transform: uppercase; }
.chat-live-indicator svg { width: 10px; height: 10px; }
.chat-live-indicator.syncing { background: var(--orange-soft); color: var(--orange) !important; }
.chat-live-indicator.error { background: var(--danger-soft); color: var(--danger) !important; }
.chat-live-indicator.disabled, .chat-live-indicator.waiting_credentials { background: #edf0f1; color: #69757e !important; }
.chat-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #9fb5aa #edf2ef; scrollbar-width: thin; }
.chat-list-item { display: flex; width: 100%; align-items: flex-start; gap: 11px; border: 0; border-bottom: 1px solid #e5ebe8; padding: 14px 13px; background: transparent; color: inherit; text-align: left; cursor: pointer; transition: background 150ms, box-shadow 150ms, transform 150ms; }
.chat-list-item:hover { background: #f0f5f2; }
.chat-list-item.active { background: linear-gradient(90deg, #e4f2eb, #edf7f2); box-shadow: inset 3px 0 var(--primary); }
.chat-avatar { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 13px; background: #e7ecee; color: #52616a; font-size: 11px; font-weight: 800; letter-spacing: 0.02em; box-shadow: inset 0 0 0 1px rgba(80, 103, 91, 0.05); }
.chat-avatar.instagram { background: linear-gradient(145deg, #fce9df, #f5d8e7); color: #ad4a62; }
.chat-avatar.facebook { background: #e3edfc; color: #2864b8; }
.chat-avatar.neutral svg { width: 17px; }
.chat-avatar.large { width: 58px; height: 58px; border-radius: 18px; font-size: 15px; }
.chat-list-copy { display: grid; min-width: 0; flex: 1; gap: 5px; }
.chat-list-line { display: flex; align-items: center; gap: 7px; }
.chat-list-line strong { overflow: hidden; flex: 1; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-line time { color: #829088; font-size: 9px; }
.chat-list-preview { overflow: hidden; color: #65736c; font-size: 11px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-meta { display: flex; align-items: center; gap: 6px; }
.chat-list-meta .channel-badge { font-size: 6px; }
.chat-automation-dot { display: inline-grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: #e7ecee; color: #718089; }
.chat-automation-dot.completed { background: var(--primary-soft); color: var(--primary); }
.chat-automation-dot.failed { background: var(--danger-soft); color: var(--danger); }
.chat-automation-dot.waiting_input, .chat-automation-dot.delayed { background: var(--orange-soft); color: var(--orange); }
.chat-automation-dot svg { width: 9px; height: 9px; }
.chat-session-dot { display: inline-grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: #dcefe6; color: var(--primary); }
.chat-session-dot svg { width: 9px; height: 9px; }
.chat-pending-dot { position: relative; display: inline-grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: #fff2d8; color: #9a5a0f; }
.chat-pending-dot svg { width: 9px; height: 9px; }
.chat-pending-dot small { position: absolute; top: -5px; right: -6px; min-width: 12px; border-radius: 8px; padding: 1px 3px; background: #9a5a0f; color: #fff; font-size: 6px; line-height: 9px; text-align: center; }
.chat-empty { display: grid; place-items: center; gap: 7px; margin: auto; padding: 30px 18px; color: var(--text-muted); text-align: center; }
.chat-empty svg { width: 28px; }
.chat-empty strong { color: var(--text); font-size: 10px; }
.chat-empty span { font-size: 8px; }
.chat-thread-panel { position: relative; display: grid; min-width: 0; min-height: 0; overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto; background: #eef2f0; }
.chat-thread-header { display: flex; min-height: 72px; flex: 0 0 auto; align-items: center; gap: 11px; border-bottom: 1px solid var(--border); padding: 11px 17px; background: rgba(255, 255, 255, 0.97); box-shadow: 0 4px 14px rgba(31, 52, 41, 0.04); }
.chat-thread-identity { display: grid; min-width: 0; flex: 1; gap: 3px; }
.chat-thread-header strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-header span { overflow: hidden; color: var(--text-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-header .channel-badge { margin-right: 4px; font-size: 7px; }
.chat-status-action { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #d9e1dd; border-radius: 9px; padding: 8px 10px; background: #f8faf9; color: #5e6e66; font-size: 9px; font-weight: 800; cursor: pointer; }
.chat-status-action:hover { border-color: #adc9bc; background: #eef7f2; color: var(--primary); }
.chat-status-action svg { width: 13px; height: 13px; }
.chat-thread { min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #739789 #dce7e2; scrollbar-gutter: stable; scrollbar-width: auto; padding: 24px max(20px, 5%); background-color: #edf3f0; background-image: radial-gradient(circle at 1px 1px, rgba(91, 113, 102, 0.1) 1px, transparent 0); background-size: 22px 22px; }
.chat-thread::-webkit-scrollbar { width: 13px; }
.chat-thread::-webkit-scrollbar-track { border-left: 1px solid rgba(124, 151, 138, 0.12); background: #dfe9e4; }
.chat-thread::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 12px; background: #719486; background-clip: padding-box; }
.chat-thread::-webkit-scrollbar-thumb:hover { background: #527969; background-clip: padding-box; }
.chat-scroll-latest { position: absolute; z-index: 5; right: 24px; bottom: 112px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid #aecdbf; border-radius: 999px; padding: 9px 13px; background: #fff; box-shadow: 0 8px 24px rgba(35, 71, 54, 0.2); color: var(--primary); font-size: 9px; font-weight: 800; cursor: pointer; }
.chat-scroll-latest:hover { background: #eef8f3; transform: translateY(-1px); }
.chat-scroll-latest svg { width: 13px; height: 13px; }
.chat-scroll-latest.hidden { display: none; }
.chat-thread-placeholder { display: grid; height: 100%; min-height: 230px; place-content: center; justify-items: center; gap: 8px; padding: 30px; color: #7d898f; text-align: center; }
.chat-thread-placeholder > svg { width: 30px; }
.chat-thread-placeholder strong { color: #526169; font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.chat-thread-placeholder span:last-child { max-width: 330px; font-size: 9px; line-height: 15px; }
.chat-placeholder-orbit { display: grid; width: 54px; height: 54px; place-items: center; margin-bottom: 4px; border: 1px solid #bad2c6; border-radius: 50%; background: rgba(255, 255, 255, 0.74); color: var(--primary); box-shadow: 0 0 0 9px rgba(23, 107, 82, 0.05); }
.chat-placeholder-orbit svg { width: 21px; }
.chat-day-divider { position: sticky; z-index: 2; top: 0; width: max-content; margin: 5px auto 18px; border: 1px solid rgba(199, 214, 206, 0.75); border-radius: 13px; padding: 5px 10px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 3px 10px rgba(32, 47, 40, 0.07); color: #66756d; font-size: 9px; font-weight: 700; backdrop-filter: blur(7px); }
.chat-message-row { display: flex; margin-bottom: 10px; }
.chat-message-row.outbound { justify-content: flex-end; }
.chat-message-bubble { position: relative; width: fit-content; max-width: min(74%, 580px); border: 1px solid rgba(210, 221, 216, 0.65); border-radius: 6px 16px 16px 16px; padding: 11px 13px 8px; background: white; box-shadow: 0 3px 12px rgba(29, 45, 37, 0.08); }
.chat-message-row.outbound .chat-message-bubble { border-color: rgba(157, 197, 178, 0.55); border-radius: 16px 6px 16px 16px; background: linear-gradient(145deg, #daf0e5, #d3ebdf); }
.chat-message-bubble p { margin: 0; color: #2f3d36; font-size: 13px; line-height: 19px; white-space: pre-wrap; word-break: break-word; }
.chat-message-bubble time { display: block; margin-top: 5px; color: #75857c; font-size: 9px; text-align: right; }
.chat-message-actions { display: grid; gap: 4px; margin-top: 8px; }
.chat-message-actions span { display: flex; align-items: center; justify-content: center; gap: 5px; border-top: 1px solid rgba(23, 107, 82, 0.17); padding-top: 6px; color: var(--primary); font-size: 8px; font-weight: 700; }
.chat-message-actions svg { width: 10px; height: 10px; }
.chat-button-response { display: block; margin-top: 5px; color: #7a6a43; font-size: 7px; }
.chat-composer { position: relative; z-index: 3; border-top: 1px solid var(--border); padding: 11px 13px 10px; background: rgba(255, 255, 255, 0.98); box-shadow: 0 -5px 18px rgba(42, 62, 52, 0.05); }
.chat-composer > textarea { width: 100%; min-height: 52px; max-height: 140px; border: 1px solid #d8e2dd; border-radius: 12px; padding: 11px 12px; resize: vertical; background: #f9fbfa; box-shadow: none; font-size: 12px; line-height: 18px; }
.chat-composer > textarea:focus { border-color: #84b29f; background: white; box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.08); }
.chat-compose-hint { position: absolute; top: 47px; right: 26px; color: #8a9790; font-size: 8px; pointer-events: none; }
.chat-compose-actions { display: flex; align-items: center; gap: 8px; padding-top: 6px; }
.chat-compose-actions > span { color: var(--text-muted); font-size: 7px; }
.chat-send { margin-left: auto; }
.message-button-builder { display: grid; gap: 6px; border-top: 1px solid #edf0ef; padding: 8px 0 4px; }
.message-button-row { display: grid; grid-template-columns: 92px minmax(90px, 0.8fr) minmax(130px, 1.25fr) 30px; align-items: center; gap: 6px; }
.message-button-row input, .message-button-row select { min-width: 0; min-height: 32px; padding: 6px 8px; font-size: 8px; }
.chat-context-panel { overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #a6b8af #eef2f0; scrollbar-width: thin; border-left: 1px solid var(--border); }
.chat-context-empty { display: grid; place-items: center; gap: 8px; padding: 54px 22px; color: var(--text-muted); text-align: center; }
.chat-context-empty svg { width: 27px; color: var(--primary); }
.chat-context-empty strong { color: var(--text); font-size: 10px; }
.chat-context-empty span { font-size: 8px; line-height: 14px; }
.chat-contact-card { display: grid; justify-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding: 24px 16px 20px; background: white; text-align: center; }
.chat-contact-card > strong { margin-top: 3px; font-family: Georgia, "Times New Roman", serif; font-size: 14px; }
.chat-contact-card > span:not(.channel-badge) { max-width: 100%; overflow: hidden; color: var(--text-muted); font-size: 8px; text-overflow: ellipsis; }
.chat-session-card { display: flex; align-items: flex-start; gap: 9px; border-bottom: 1px solid var(--border); padding: 12px 14px; background: #eef7f2; }
.chat-session-card.inactive { background: #f7f9f8; }
.chat-session-icon { display: grid; width: 28px; height: 28px; flex: 0 0 auto; place-items: center; border-radius: 8px; background: #d8ece2; color: var(--primary); }
.chat-session-card.inactive .chat-session-icon { background: #e8ecea; color: #7c8881; }
.chat-session-icon svg { width: 14px; height: 14px; }
.chat-session-card > div:last-child { display: grid; gap: 3px; }
.chat-session-card strong { color: #315c49; font-size: 8px; }
.chat-session-card span { color: #687970; font-size: 7px; line-height: 12px; }
.chat-session-close { width: max-content; border: 0; padding: 3px 0 0; background: transparent; color: var(--primary); font-size: 7px; font-weight: 800; cursor: pointer; }
.chat-session-close:hover { text-decoration: underline; }
.chat-context-section { border-bottom: 1px solid var(--border); padding: 16px 14px; }
.chat-context-label { color: #66736c; font-size: 8px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.chat-context-section p { margin: 6px 0 10px; color: var(--text-muted); font-size: 8px; line-height: 13px; }
.chat-context-section select { width: 100%; margin-bottom: 8px; font-size: 9px; }
.chat-run-history { display: grid; gap: 7px; margin-top: 10px; }
.chat-run-item { display: flex; align-items: flex-start; gap: 7px; border-radius: 6px; padding: 7px; background: white; }
.chat-run-item > div { display: grid; min-width: 0; gap: 2px; }
.chat-run-item strong { overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.chat-run-item time, .chat-run-empty { color: var(--text-muted); font-size: 7px; }
.chat-broker-pending-list { display: grid; gap: 7px; margin-top: 10px; }
.chat-broker-pending-item { display: grid; gap: 4px; border: 1px solid #f0d9ad; border-radius: 7px; padding: 9px; background: #fffaf0; }
.chat-broker-pending-item strong { color: #71420d; font-size: 8px; line-height: 12px; }
.chat-broker-pending-item small { color: #8a6a3d; font-size: 7px; line-height: 11px; }
.chat-broker-pending-item p { margin: 0; color: #6c6253; font-size: 8px; line-height: 13px; }
.automation-inline-section { display: grid; gap: 8px; margin-top: 14px; border-top: 1px solid var(--border); padding-top: 13px; }
.automation-inline-heading, .automation-button-row-head { display: flex; align-items: center; justify-content: space-between; }
.automation-inline-heading span { color: #68747e; font-size: 8px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.automation-inline-heading small { color: var(--text-muted); font-size: 8px; }
.automation-button-row { display: grid; gap: 7px; border: 1px solid var(--border); border-radius: 7px; padding: 9px; background: #f8faf9; }
.automation-button-row-head strong { color: #59676f; font-size: 8px; }
.automation-button-row-head .icon-button { width: 25px; height: 25px; }
.automation-button-row .field + .field { margin-top: 0; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast {
  display: flex;
  width: min(360px, calc(100vw - 36px));
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  padding: 11px 13px;
  background: white;
  box-shadow: var(--shadow);
  color: #35414d;
  font-size: 11px;
  line-height: 16px;
}
.toast.error { border-left-color: var(--danger); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 31, 0.54);
}
.modal {
  position: relative;
  width: min(440px, 100%);
  border-radius: 8px;
  padding: 28px;
  background: white;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.modal-close { position: absolute; top: 9px; right: 9px; }
.modal-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
}
.modal-icon.success { background: var(--primary-soft); color: var(--primary); }
.modal-icon.error { background: var(--danger-soft); color: var(--danger); }
.modal-icon svg { width: 22px; height: 22px; }
.modal-icon.loading svg { animation: spin 1s linear infinite; }
.modal h2 { font-size: 16px; }
.modal > p { margin: 7px 0 15px; color: var(--text-muted); font-size: 11px; line-height: 17px; }
.modal .result-box { margin-bottom: 15px; text-align: left; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

@media (max-width: 980px) {
  .work-grid { grid-template-columns: 1fr; }
  .setup-steps ol { grid-template-columns: repeat(2, 1fr); }
  .chat-workspace { grid-template-columns: minmax(225px, 0.7fr) minmax(0, 1.5fr); overflow: hidden; }
  .chat-context-panel { display: none; }
  .automation-builder { grid-template-columns: 210px minmax(540px, 1fr); overflow: auto; }
  .automation-inspector { position: absolute; z-index: 8; right: 0; width: 286px; height: 100%; box-shadow: -10px 0 25px rgba(24, 33, 43, 0.12); }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform 180ms; }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25); }
  .main { margin-left: 0; }
  .mobile-menu { display: inline-grid !important; }
  .form-grid { grid-template-columns: 1fr; }
  .guide.wide { grid-column: auto; }
  .topbar { padding: 11px 16px; }
  .topbar p { display: none; }
  .content { padding: 20px 16px 50px; }
  .api-health span:last-child { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .button, .toolbar select { flex: 1 1 auto; }
  .webhook-summary { align-items: flex-start; flex-direction: column; }
  .setup-steps ol { grid-template-columns: 1fr; }
  .webhook-event { grid-template-columns: 1fr; }
  .content.automation-content { padding: 12px; }
  .content.chat-content { padding: 10px; }
  .chat-toolbar { flex-wrap: wrap; }
  .chat-search { max-width: none; flex: 1 1 100%; }
  .chat-toolbar select, .chat-toolbar .button { flex: 1; }
  .chat-workspace { width: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: 190px minmax(0, 1fr); height: calc(100dvh - 238px); min-height: 510px; }
  .chat-list-panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .chat-pane-heading { min-height: 55px; padding: 9px 13px; }
  .chat-list { display: flex; overflow-x: auto; overflow-y: hidden; }
  .chat-list-item { width: 230px; min-width: 230px; border-right: 1px solid #e5ebe8; border-bottom: 0; }
  .chat-list-item.active { box-shadow: inset 0 -3px var(--primary); }
  .chat-thread-header { min-height: 61px; padding: 9px 12px; }
  .chat-thread { padding: 18px 14px; }
  .chat-message-bubble { max-width: 86%; }
  .chat-scroll-latest { right: 18px; bottom: 106px; }
  .message-button-row { grid-template-columns: 80px 1fr 30px; }
  .message-button-row input:nth-of-type(2) { grid-column: 1 / 3; }
  .automation-topbar { align-items: flex-start; flex-direction: column; }
  .automation-actions { width: 100%; }
  .automation-actions .button { flex: 1; }
  .automation-builder { grid-template-columns: 190px minmax(520px, 1fr); height: calc(100vh - 230px); min-height: 560px; }
}

@media (max-width: 520px) {
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading .button { width: 100%; }
  .sticky-actions { align-items: stretch; flex-direction: column; }
  .save-state { display: none; }
  .sticky-actions { padding: 7px; }
  .sticky-actions .button { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  th:nth-child(1) { width: 72px; }
  th:nth-child(2) { width: 124px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  .automation-actions .button span { display: none; }
  .automation-inspector { width: min(286px, 82vw); }
  .automation-test-grid { grid-template-columns: 1fr; }
  .automation-test-grid .full { grid-column: auto; }
  .content.chat-content { padding: 7px; }
  .chat-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px; gap: 6px; margin-bottom: 7px; border-radius: 10px; padding: 7px; }
  .chat-search { min-width: 0; grid-column: 1 / -1; }
  .chat-toolbar select { width: 100%; min-width: 0; font-size: 10px; }
  #chat-channel-filter, #chat-status-filter { width: 100%; }
  .chat-toolbar > .button { width: 42px; min-width: 42px; justify-content: center; padding: 0; }
  .chat-toolbar > .button span { display: none; }
  .chat-workspace { height: calc(100dvh - 230px); min-height: 470px; border-radius: 11px; }
  .chat-thread-panel { width: 100%; }
  .chat-status-action span { display: none; }
  .chat-status-action { width: 35px; height: 35px; justify-content: center; padding: 0; }
  .chat-thread-header .chat-avatar { width: 35px; height: 35px; }
  .chat-thread { padding: 16px 10px; }
  .chat-message-bubble { max-width: 92%; }
  .chat-compose-actions { min-width: 0; }
  .chat-compose-actions .button { min-width: 0; }
  .chat-compose-hint { display: none; }
  .chat-compose-actions > span { display: none; }
}

/* Chat inbox redesign */
.content.chat-content {
  width: 100%;
  max-width: 1680px;
  padding: 16px clamp(16px, 2vw, 30px);
}

.chat-workspace {
  display: grid;
  width: 100%;
  height: calc(100dvh - 108px);
  min-height: 620px;
  grid-template-columns: minmax(280px, 0.82fr) minmax(440px, 1.85fr) minmax(260px, 0.8fr);
  overflow: hidden;
  border: 1px solid #d9e2dd;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(33, 54, 43, 0.1);
}

.chat-list-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  border-right: 1px solid #dfe7e3;
  background: #fbfcfb;
}

.chat-inbox-header {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  border-bottom: 1px solid #e4ebe7;
  padding: 18px 16px 12px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(39, 60, 49, 0.035);
}

.chat-pane-heading {
  display: flex;
  min-height: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  padding: 0 1px 14px;
  background: transparent;
}

.chat-pane-heading > div { display: grid; gap: 2px; }
.chat-pane-heading strong { color: #172a21; font-family: Georgia, "Times New Roman", serif; font-size: 22px; line-height: 28px; }
.chat-eyebrow { color: #7b8a82 !important; font-size: 9px !important; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.chat-live-indicator { margin-top: 3px; padding: 5px 8px; font-size: 8px !important; letter-spacing: 0.03em; white-space: nowrap; }

.chat-search { position: relative; min-width: 0; }
.chat-search svg { left: 13px; width: 15px; height: 15px; color: #74847b; }
.chat-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #dce5e0;
  border-radius: 11px;
  padding: 9px 12px 9px 38px;
  background: #f6f9f7;
  font-size: 11px;
}
.chat-search input:focus { border-color: #87ad9d; background: #fff; box-shadow: 0 0 0 3px rgba(23, 107, 82, 0.08); }

.chat-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) 38px 38px;
  gap: 6px;
  margin: 8px 0 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.chat-toolbar select, #chat-channel-filter, #chat-status-filter {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border-color: #dce5e0;
  border-radius: 9px;
  padding: 6px 23px 6px 9px;
  background-color: #fff;
  color: #526159;
  font-size: 9px;
}
.chat-refresh-button {
  display: grid;
  width: 38px;
  height: 36px;
  place-items: center;
  border: 1px solid #dce5e0;
  border-radius: 9px;
  background: #fff;
  color: #52665c;
}
.chat-refresh-button:hover { border-color: #8fb5a4; background: #eef7f2; color: var(--primary); }
.chat-refresh-button svg { width: 14px; height: 14px; }
.chat-list-summary { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px 0; color: #87948d; font-size: 8px; }
.chat-list-summary span:first-child { color: #54655c; font-weight: 800; }

.chat-list {
  display: block;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 7px 8px 12px;
  scrollbar-color: #a7bab0 transparent;
  scrollbar-width: thin;
}
.chat-list-item {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: flex-start;
  gap: 11px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 10px;
  background: transparent;
  transition: border-color 150ms, background 150ms, transform 150ms;
}
.chat-list-item:hover { border-color: #e1e9e5; background: #f2f6f4; transform: translateX(1px); }
.chat-list-item.active { border-color: #cce0d6; background: #e9f4ef; box-shadow: none; }
.chat-list-item.active::before { position: absolute; inset: 12px auto 12px -1px; width: 3px; border-radius: 0 4px 4px 0; background: var(--primary); content: ""; }
.chat-list-item .chat-avatar { width: 42px; height: 42px; border-radius: 14px; }
.chat-list-line strong { color: #26362e; font-size: 11px; }
.chat-list-line time { font-size: 8px; }
.chat-list-preview { color: #637169; font-size: 10px; line-height: 15px; }
.chat-list-meta .channel-badge { padding: 3px 6px; font-size: 6px; }

.chat-thread-panel {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: 76px minmax(0, 1fr) auto;
  background: #edf3f0;
}
.chat-thread-header {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid #dce6e1;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 5px 18px rgba(32, 52, 42, 0.04);
}
.chat-back-button { display: none; }
.chat-thread-header .chat-avatar { width: 42px; height: 42px; border-radius: 14px; }
.chat-thread-identity { display: grid; min-width: 0; flex: 1; gap: 4px; }
.chat-thread-header strong { color: #203129; font-size: 13px; }
.chat-thread-header span { font-size: 9px; }
.chat-status-action { border-radius: 10px; padding: 8px 10px; background: #fff; font-size: 9px; }

.chat-thread {
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px clamp(18px, 5%, 54px);
  background-color: #edf3f0;
  background-image: radial-gradient(circle at 1px 1px, rgba(72, 105, 88, 0.1) 1px, transparent 0);
  background-size: 23px 23px;
  scrollbar-color: #78998a #dfe9e4;
  scrollbar-gutter: stable;
}
.chat-thread::-webkit-scrollbar { width: 11px; }
.chat-thread::-webkit-scrollbar-track { background: #dfe9e4; }
.chat-thread::-webkit-scrollbar-thumb { border: 3px solid #dfe9e4; border-radius: 10px; background: #6f9283; }
.chat-day-divider { top: 4px; margin-bottom: 20px; padding: 5px 11px; }
.chat-message-row { margin-bottom: 11px; }
.chat-message-bubble { max-width: min(72%, 600px); border-radius: 7px 17px 17px; padding: 11px 13px 8px; }
.chat-message-row.outbound .chat-message-bubble { border-radius: 17px 7px 17px 17px; background: #d8ede3; }
.chat-message-bubble p { font-size: 12px; line-height: 18px; }
.chat-message-bubble time { font-size: 8px; }
.chat-scroll-latest { right: 24px; bottom: 116px; }

.chat-composer {
  position: relative;
  z-index: 4;
  border-top: 1px solid #dce6e1;
  padding: 12px 14px 11px;
  background: #fff;
  box-shadow: 0 -5px 20px rgba(36, 55, 46, 0.04);
}
.chat-composer > textarea { min-height: 54px; border-radius: 13px; background: #f7faf8; font-size: 11px; }
.chat-compose-actions { padding-top: 8px; }
.chat-compose-actions .button { min-height: 34px; border-radius: 9px; }
.chat-send { min-width: 92px; }

.chat-context-panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid #dfe7e3;
  background: #fafcfb;
}
.chat-context-heading { display: grid; gap: 2px; border-bottom: 1px solid #e1e8e4; padding: 18px 16px 14px; background: #fff; }
.chat-context-heading span { color: #7c8a83; font-size: 8px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.chat-context-heading strong { color: #26372f; font-size: 12px; }
.chat-contact-card { padding: 22px 16px 18px; background: #fff; }
.chat-contact-card > strong { font-size: 15px; }
.chat-contact-card > span:not(.channel-badge) { font-size: 9px; }
.chat-session-card { margin: 12px; border: 1px solid #dce7e1; border-radius: 12px; padding: 11px; }
.chat-context-section { margin: 0 12px; border-bottom: 1px solid #e1e8e4; padding: 16px 2px; }
.chat-context-label { font-size: 8px; }
.chat-context-section p { font-size: 9px; line-height: 14px; }
.chat-run-item { border: 1px solid #e5ebe8; border-radius: 9px; }

@media (max-width: 1180px) {
  .chat-workspace { grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.7fr); }
  .chat-context-panel { display: none; }
}

@media (max-width: 760px) {
  .content.chat-content { height: calc(100dvh - 76px); padding: 0; }
  .chat-workspace { display: block; height: 100%; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  .chat-list-panel { display: flex; width: 100%; height: 100%; border: 0; }
  .chat-inbox-header { padding: 16px 14px 11px; }
  .chat-pane-heading { padding-bottom: 12px; }
  .chat-pane-heading strong { font-size: 21px; }
  .chat-list { display: block; overflow-x: hidden; overflow-y: auto; padding: 7px 8px 16px; }
  .chat-list-item { width: 100%; min-width: 0; border-right: 0; }
  .chat-list-item.active { box-shadow: none; }
  .chat-thread-panel { display: none; width: 100%; height: 100%; grid-template-rows: 68px minmax(0, 1fr) auto; }
  .chat-workspace.chat-open .chat-list-panel { display: none; }
  .chat-workspace.chat-open .chat-thread-panel { display: grid; }
  .chat-back-button { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid #dce5e0; border-radius: 10px; background: #f7faf8; color: #4d6257; }
  .chat-back-button svg { width: 16px; height: 16px; }
  .chat-thread-header { min-height: 68px; padding: 9px 12px; }
  .chat-thread { padding: 19px 13px; }
  .chat-message-bubble { max-width: 88%; }
  .chat-context-panel { display: none; }
}

@media (max-width: 520px) {
  .chat-inbox-header { padding: 14px 12px 10px; }
  .chat-toolbar { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) 38px 38px; }
  .chat-toolbar select, #chat-channel-filter, #chat-status-filter { width: 100%; font-size: 9px; }
  .chat-list-item { padding: 12px 9px; }
  .chat-thread-header .chat-avatar { width: 38px; height: 38px; }
  .chat-thread-header .chat-status-action { width: 36px; height: 36px; }
  .chat-thread-header .chat-status-action span { display: none; }
  .chat-message-bubble { max-width: 92%; }
  .chat-composer { padding: 10px; }
  .chat-compose-hint, .chat-compose-actions > span { display: none; }
}

.comment-live-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid #d8e6df;
  border-radius: 12px;
  padding: 12px 14px;
  background: #f0f8f4;
}
.comment-live-card.warning { border-color: #efd0a7; background: #fff7ed; }
.comment-live-card.checking { background: #f5f7f8; }
.comment-live-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: #dceee5; color: var(--primary); }
.comment-live-card.warning .comment-live-icon { background: #f9e6ca; color: var(--orange); }
.comment-live-icon svg { width: 17px; height: 17px; }
.comment-live-card > div:not(.comment-live-actions) { display: grid; gap: 3px; }
.comment-live-card strong { color: #274337; font-size: 11px; }
.comment-live-card.warning strong { color: #754918; }
.comment-live-card > div:not(.comment-live-actions) span { color: #62736a; font-size: 9px; line-height: 14px; }
.comment-live-card .button { white-space: nowrap; }
.comment-live-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.automation-trigger-guidance { margin: 10px 0 0; border: 1px solid #cfe2d8; border-radius: 9px; padding: 9px 10px; background: #eef7f2; color: #50675b; font-size: 8px; line-height: 13px; }
.automation-trigger-guidance strong { display: block; margin-bottom: 2px; color: var(--primary); font-size: 9px; }

.chat-feed-share-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: min(310px, 64vw);
  margin: -4px -6px 8px;
  border: 1px solid #d7e4dd;
  border-radius: 11px;
  padding: 7px;
  background: #f7faf8;
  color: inherit;
  text-decoration: none;
}
.chat-feed-share-card:hover { border-color: #a8c9b9; background: #f0f7f3; }
.chat-feed-share-media { display: grid; width: 54px; height: 54px; overflow: hidden; place-items: center; border-radius: 8px; background: #e3eee8; color: var(--primary); }
.chat-feed-share-media img { width: 100%; height: 100%; object-fit: cover; }
.chat-feed-share-media svg { width: 20px; height: 20px; }
.chat-feed-share-copy { display: grid; gap: 3px; min-width: 0; }
.chat-feed-share-copy strong { overflow: hidden; color: #274337; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-feed-share-copy small { color: #718178; font-size: 8px; line-height: 12px; }
.chat-feed-share-card > svg { width: 13px; height: 13px; color: #75877e; }

@media (max-width: 760px) {
  .comment-live-card { grid-template-columns: 38px minmax(0, 1fr); }
  .comment-live-actions { grid-column: 1 / -1; width: 100%; }
  .comment-live-card .button { flex: 1; }
}

/* Automation workspace v2 */
.automation-mobile-tabs { display: none; }
.automation-builder {
  grid-template-columns: 252px minmax(460px, 1fr) 360px;
  border-color: #cbd8d1;
  border-radius: 16px;
  background: #e7ece9;
  box-shadow: 0 22px 58px rgba(31, 52, 42, 0.13);
}
.automation-library,
.automation-studio-panel {
  position: relative;
  z-index: 4;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #fbfcfb;
}
.automation-library { border-right: 1px solid #d9e3de; }
.automation-studio-panel { border-left: 1px solid #d6e0db; }
.automation-flow-list { max-height: min(34vh, 290px); padding: 9px; }
.automation-flow-item { margin-bottom: 3px; border-radius: 10px; padding: 11px 10px; }
.automation-flow-item.active { border-color: #b8d7ca; background: linear-gradient(135deg, #e8f4ee, #f2f8f5); box-shadow: inset 3px 0 #176b52; }
.automation-palette { min-height: 0; overflow: auto; padding: 13px 12px 16px; }
.automation-palette-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.automation-palette-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.automation-palette-group > small { grid-column: 1 / -1; color: #849087; font-size: 7px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.automation-palette-grid .automation-palette-group button {
  display: flex;
  min-height: 39px;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
  border-radius: 9px;
  padding: 7px 8px;
  font-size: 8px;
  text-align: left;
}
.automation-palette-grid .automation-palette-group button svg { width: 14px; height: 14px; flex: 0 0 auto; }
.automation-palette-grid .automation-palette-group button:disabled { border-style: dashed; background: #f3f5f4; }
.automation-canvas-panel { background: #dfe7e3; }
.automation-canvas { background-color: #edf2ef; background-image: radial-gradient(circle, #b9c9c1 1px, transparent 1px); }
.automation-canvas-toolbar { border-color: rgba(190, 207, 198, 0.95); border-radius: 10px; box-shadow: 0 8px 22px rgba(38, 61, 50, 0.09); }
.automation-validation-summary {
  position: absolute;
  top: 62px;
  left: 12px;
  z-index: 3;
  width: min(310px, calc(100% - 24px));
  overflow: hidden;
  border: 1px solid #e3c7a9;
  border-radius: 11px;
  background: rgba(255, 249, 241, 0.96);
  box-shadow: 0 8px 24px rgba(85, 60, 34, 0.09);
  backdrop-filter: blur(8px);
}
.automation-validation-summary.empty { display: none; }
.automation-validation-summary.valid { display: flex; width: auto; align-items: center; gap: 6px; border-color: #c8ddd3; padding: 8px 10px; background: rgba(241, 249, 245, 0.96); color: #2c6b52; font-size: 8px; font-weight: 700; }
.automation-validation-summary.valid svg { width: 14px; height: 14px; }
.automation-validation-summary.invalid > div:first-child { display: flex; align-items: center; gap: 8px; padding: 9px 10px; color: #8b521d; }
.automation-validation-summary.invalid > div:first-child > svg { width: 15px; height: 15px; flex: 0 0 auto; }
.automation-validation-summary.invalid > div:first-child span { display: grid; gap: 1px; }
.automation-validation-summary.invalid strong { font-size: 9px; }
.automation-validation-summary.invalid small { color: #9a7655; font-size: 7px; }
.automation-validation-list { display: grid; border-top: 1px solid #efddca; padding: 5px; }
.automation-validation-list button { border: 0; border-radius: 6px; padding: 5px 6px; background: transparent; color: #775535; font-size: 7px; line-height: 11px; text-align: left; }
.automation-validation-list button:hover { background: #f8eadb; }
.automation-validation-list > small { padding: 4px 6px; }
.automation-node { width: 210px; min-height: 92px; border-radius: 11px; border-top-width: 4px; box-shadow: 0 10px 25px rgba(36, 58, 47, 0.13); }
.automation-node.invalid { border-right-color: #d9958f; border-bottom-color: #d9958f; border-left-color: #d9958f; }
.automation-node.invalid::after { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border: 2px solid white; border-radius: 50%; background: #c24135; box-shadow: 0 0 0 1px #c24135; content: ""; }
.automation-node-header { padding: 10px 11px 8px; }
.automation-node-summary { min-height: 30px; padding: 7px 11px; line-height: 13px; }
.automation-node-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 9px; }
.automation-node-chips span { border-radius: 10px; padding: 3px 6px; background: #edf1ef; color: #5d6d65; font-size: 6px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }
.automation-node-chips .waiting { background: #fff0df; color: #9b5a1d; }
.automation-node-chips .buttons { background: #e8f1fb; color: #34648f; }
.automation-node-chips .condition { background: #edf1f7; color: #48647f; }
.automation-node-chips .ai { background: #f0e8f7; color: #694596; }
.automation-node-chips .trigger { background: #fff0e3; color: #9d5a21; }
.automation-studio-tabs { display: grid; min-height: 49px; grid-template-columns: 1fr 1fr auto; border-bottom: 1px solid #dce5e0; padding: 6px; background: #f4f7f5; }
.automation-studio-tabs > button { display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 7px 9px; background: transparent; color: #728078; font-size: 8px; font-weight: 700; }
.automation-studio-tabs > button.active { background: white; color: #176b52; box-shadow: 0 2px 9px rgba(32, 53, 43, 0.09); }
.automation-studio-tabs svg { width: 14px; height: 14px; }
.automation-studio-tabs .automation-studio-close { display: none; width: 32px; padding: 0; }
.automation-studio-view { display: none; min-height: 0; flex: 1; flex-direction: column; }
.automation-studio-view.active { display: flex; }
.automation-inspector-content { min-height: 0; flex: 1; padding: 15px; }
.automation-trigger-card { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; margin-bottom: 18px; border: 1px solid #e3d1bc; border-radius: 12px; padding: 12px; background: linear-gradient(145deg, #fff8ef, #fffdf9); }
.automation-trigger-card-icon { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: #f8dec1; color: #9c581d; }
.automation-trigger-card-icon svg { width: 17px; height: 17px; }
.automation-trigger-card > div { display: grid; gap: 2px; }
.automation-trigger-card small { color: #9a7757; font-size: 7px; font-weight: 700; text-transform: uppercase; }
.automation-trigger-card strong { color: #5e3b20; font-size: 10px; }
.automation-trigger-card p { margin: 3px 0 0; color: #856d59; font-size: 7px; line-height: 12px; }
.automation-ai-intents-dialog { width: min(720px, 100%); text-align: left; }
.automation-ai-intent-form { display: grid; grid-template-columns: minmax(160px, 0.65fr) minmax(260px, 1.35fr); gap: 12px; margin: 17px 0; border: 1px solid #ddd2e7; border-radius: 11px; padding: 13px; background: #faf8fc; }
.automation-ai-intent-form .automation-test-actions { grid-column: 1 / -1; }
.automation-ai-intent-list { display: grid; max-height: min(360px, 45vh); overflow-y: auto; gap: 7px; }
.automation-ai-intent-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid #d9e1dd; border-radius: 10px; padding: 11px 12px; background: white; }
.automation-ai-intent-item.inactive { background: #f2f4f3; opacity: 0.72; }
.automation-ai-intent-item > div:first-child { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; }
.automation-ai-intent-item strong { color: #34283f; font-size: 10px; }
.automation-ai-intent-item span { color: #7650a8; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.automation-ai-intent-item p { grid-column: 1 / -1; margin: 0; color: #6f6875; font-size: 8px; line-height: 13px; }
.automation-ai-intent-actions { display: flex; align-items: center; gap: 6px; }
@media (max-width: 620px) {
  .automation-ai-intent-form { grid-template-columns: 1fr; }
  .automation-ai-intent-form .automation-test-actions { grid-column: auto; }
  .automation-ai-intent-item { grid-template-columns: 1fr; }
}
.automation-simulator-view { overflow-y: auto; padding: 0 14px 17px; background: linear-gradient(180deg, #f8faf9 0%, #edf3f0 100%); }
.automation-simulator-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -14px 12px; border-bottom: 1px solid #dfe7e3; padding: 11px 14px; background: white; }
.automation-simulator-heading > div { display: grid; gap: 2px; }
.automation-simulator-heading span { color: #2c3e35; font-size: 10px; font-weight: 800; }
.automation-simulator-heading small { color: #839087; font-size: 7px; }
.automation-simulator-setup { display: grid; grid-template-columns: 0.72fr 1.28fr; gap: 7px; margin-bottom: 11px; }
.automation-simulator-setup .field label { margin-bottom: 4px; font-size: 7px; }
.automation-simulator-setup .field input,
.automation-simulator-setup .field select { min-height: 34px; border-radius: 8px; padding: 6px 8px; font-size: 8px; }
.automation-simulator-setup #automation-simulator-payload-wrap,
.automation-simulator-setup .button { grid-column: 1 / -1; }
.automation-simulator-setup .button { min-height: 34px; }
.automation-comment-preview { display: grid; gap: 5px; margin-bottom: 10px; border: 1px solid #ded6ce; border-radius: 10px; padding: 9px; background: #fff; }
.automation-comment-preview > div { display: grid; grid-template-columns: auto 1fr; gap: 3px 6px; }
.automation-comment-preview span { color: #a0714f; font-size: 6px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.automation-comment-preview strong { color: #493a30; font-size: 8px; }
.automation-comment-preview p { grid-column: 1 / -1; margin: 0; color: #66574c; font-size: 8px; line-height: 12px; }
.automation-comment-preview .reply { margin-left: 16px; border-left: 2px solid #d8b997; padding-left: 8px; }
.automation-phone-shell { position: relative; width: 276px; margin: 0 auto 10px; border: 7px solid #17211c; border-radius: 34px; padding: 6px; background: #17211c; box-shadow: 0 18px 45px rgba(28, 45, 36, 0.24); }
.automation-phone-notch { position: absolute; top: 7px; left: 50%; z-index: 3; width: 78px; height: 18px; border-radius: 0 0 13px 13px; background: #17211c; transform: translateX(-50%); }
.automation-phone-screen { display: grid; height: 454px; overflow: hidden; grid-template-rows: 52px minmax(0, 1fr) auto 45px; border-radius: 23px; background: #edf4f0; }
.automation-phone-header { display: flex; align-items: center; gap: 8px; padding: 14px 11px 8px; background: #fff; box-shadow: 0 4px 15px rgba(35, 53, 44, 0.06); }
.automation-phone-avatar { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 10px; background: #dcefe6; color: #176b52; font-size: 9px; font-weight: 800; }
.automation-phone-header > div { display: grid; min-width: 0; flex: 1; gap: 1px; }
.automation-phone-header strong { font-size: 9px; }
.automation-phone-header small { overflow: hidden; color: #78877f; font-size: 6px; text-overflow: ellipsis; white-space: nowrap; }
.automation-phone-header > svg { width: 14px; height: 14px; color: #698078; }
.automation-phone-chat { min-height: 0; overflow-y: auto; padding: 14px 10px; background-color: #edf4f0; background-image: radial-gradient(circle at 1px 1px, rgba(58, 93, 74, 0.08) 1px, transparent 0); background-size: 18px 18px; }
.automation-phone-empty { display: grid; height: 100%; place-content: center; place-items: center; gap: 5px; padding: 20px; color: #7b8b83; text-align: center; }
.automation-phone-empty svg { width: 24px; height: 24px; }
.automation-phone-empty strong { color: #40554a; font-size: 9px; }
.automation-phone-empty span { font-size: 7px; line-height: 12px; }
.automation-phone-message { display: flex; margin-bottom: 8px; }
.automation-phone-message.inbound { justify-content: flex-end; }
.automation-phone-message > div { display: grid; max-width: 83%; grid-template-columns: 1fr auto; gap: 3px 7px; border-radius: 5px 13px 13px; padding: 8px 9px 6px; background: #fff; box-shadow: 0 2px 8px rgba(34, 54, 44, 0.06); }
.automation-phone-message.inbound > div { border-radius: 13px 5px 13px 13px; background: #d5ecdf; }
.automation-phone-message p { grid-column: 1 / -1; margin: 0; color: #2d3c34; font-size: 8px; line-height: 13px; white-space: pre-wrap; }
.automation-phone-message small { display: flex; align-items: center; gap: 2px; color: #668074; font-size: 5px; }
.automation-phone-message small svg { width: 7px; height: 7px; }
.automation-phone-message time { align-self: end; color: #89958f; font-size: 5px; }
.automation-quick-replies { display: flex; overflow-x: auto; gap: 5px; padding: 5px 8px; }
.automation-quick-replies:empty { display: none; }
.automation-quick-replies button { flex: 0 0 auto; border: 1px solid #78a892; border-radius: 13px; padding: 5px 8px; background: #fff; color: #176b52; font-size: 6px; font-weight: 700; }
.automation-quick-replies button:disabled { opacity: 0.5; }
.automation-phone-compose { display: grid; grid-template-columns: 1fr 32px; gap: 6px; border-top: 1px solid #dce6e1; padding: 6px 7px; background: #fff; }
.automation-phone-compose input { min-width: 0; min-height: 32px; border: 1px solid #d9e3de; border-radius: 16px; padding: 7px 10px; background: #f7faf8; font-size: 7px; }
.automation-phone-compose button { display: grid; width: 32px; height: 32px; place-items: center; border: 0; border-radius: 50%; background: #176b52; color: #fff; }
.automation-phone-compose button:disabled { background: #b5c1bb; }
.automation-phone-compose button svg { width: 13px; height: 13px; }
.automation-simulator-note { margin: 7px 4px 0; color: #74827a; font-size: 7px; line-height: 12px; text-align: center; }
.webhook-automation-cta { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 14px; margin: 18px 0 24px; border: 1px solid #cfe0d7; border-radius: 14px; padding: 15px 17px; background: linear-gradient(120deg, #edf7f2, #fbfdfc); box-shadow: 0 8px 25px rgba(35, 65, 50, 0.06); }
.webhook-automation-cta > span { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 14px; background: #d9eee4; color: #176b52; }
.webhook-automation-cta > span svg { width: 21px; height: 21px; }
.webhook-automation-cta > div { display: grid; gap: 3px; }
.webhook-automation-cta strong { color: #294238; font-size: 11px; }
.webhook-automation-cta p { margin: 0; color: #6b7c73; font-size: 9px; line-height: 14px; }

@media (max-width: 1180px) {
  .automation-builder { position: relative; grid-template-columns: 220px minmax(520px, 1fr); }
  .automation-builder.library-collapsed { grid-template-columns: minmax(0, 1fr); }
  .automation-builder.library-collapsed > .automation-library { display: none; }
  .automation-library-toggle { display: inline-grid; }
  .automation-studio-panel { position: fixed; inset: 76px 0 0 auto; z-index: 35; width: min(390px, 94vw); border-left: 1px solid #ccd9d2; box-shadow: -18px 0 48px rgba(24, 43, 34, 0.2); transform: translateX(105%); transition: transform 220ms ease; }
  .automation-studio-panel.open { transform: translateX(0); }
  .automation-studio-tabs .automation-studio-close { display: flex; }
  .automation-phone-shell { width: 286px; }
}

@media (max-width: 760px) {
  .content.automation-content { height: calc(100dvh - 76px); padding: 8px; }
  .automation-topbar { min-height: 62px; margin-bottom: 7px; border-radius: 12px; padding: 8px 9px 8px 12px; }
  .automation-title-block > span:last-child { display: none; }
  .automation-title-block strong { max-width: 160px; }
  .automation-actions { gap: 4px; }
  .automation-actions { display: grid; width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .automation-actions .button { width: 100%; min-width: 0; min-height: 36px; justify-content: center; padding: 0; }
  .automation-actions .button span { display: none; }
  .automation-mobile-tabs { display: grid; overflow: hidden; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 7px; border: 1px solid #d5dfda; border-radius: 11px; padding: 4px; background: #fff; }
  .automation-mobile-tabs button { display: flex; min-width: 0; min-height: 36px; align-items: center; justify-content: center; gap: 5px; border: 0; border-radius: 8px; background: transparent; color: #75837b; font-size: 8px; font-weight: 700; }
  .automation-mobile-tabs button.active { background: #e8f3ed; color: #176b52; }
  .automation-mobile-tabs svg { width: 13px; height: 13px; }
  .automation-builder { display: block; height: calc(100dvh - 164px); min-height: 480px; border-radius: 12px; }
  .automation-library-toggle { display: none; }
  .automation-builder > .automation-library,
  .automation-builder > .automation-canvas-panel,
  .automation-builder > .automation-studio-panel { display: none; }
  .automation-builder[data-mobile-panel="flows"] > .automation-library { display: flex; width: 100%; height: 100%; border: 0; }
  .automation-builder[data-mobile-panel="builder"] > .automation-canvas-panel { display: block; width: 100%; height: 100%; }
  .automation-builder[data-mobile-panel="simulator"] > .automation-studio-panel { position: static; display: flex; width: 100%; height: 100%; border: 0; box-shadow: none; transform: none; }
  .automation-flow-list { max-height: 42%; }
  .automation-palette { margin-top: 0; }
  .automation-palette-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .automation-palette-group { align-content: start; }
  .automation-studio-panel.inspector-sheet { position: fixed; inset: auto 0 0; z-index: 45; display: flex; width: 100%; max-height: 76dvh; border: 1px solid #ccd9d2; border-radius: 18px 18px 0 0; box-shadow: 0 -18px 50px rgba(25, 45, 35, 0.24); transform: none; animation: automation-sheet-in 180ms ease-out; }
  .automation-studio-panel.inspector-sheet [data-automation-studio-view="simulate"] { display: none; }
  .automation-studio-panel.inspector-sheet [data-automation-studio-view="configure"] { display: flex; }
  .automation-studio-panel.inspector-sheet .automation-studio-tabs > button:not(.automation-studio-close) { display: none; }
  .automation-studio-panel.inspector-sheet .automation-studio-tabs { display: flex; justify-content: flex-end; min-height: 43px; }
  .automation-studio-panel.inspector-sheet .automation-studio-close { display: flex; }
  .automation-validation-summary { top: 60px; }
  .automation-canvas-toolbar > span { max-width: 230px; }
  .automation-simulator-view { padding-right: max(14px, calc((100% - 360px) / 2)); padding-left: max(14px, calc((100% - 360px) / 2)); }
  .automation-simulator-heading { margin-right: min(-14px, calc((360px - 100%) / 2)); margin-left: min(-14px, calc((360px - 100%) / 2)); }
  .automation-phone-shell { width: min(306px, calc(100vw - 42px)); }
  .automation-phone-screen { height: min(490px, calc(100dvh - 360px)); min-height: 390px; }
  .webhook-automation-cta { grid-template-columns: 42px minmax(0, 1fr); }
  .webhook-automation-cta .button { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 420px) {
  .automation-kicker { display: none; }
  .automation-title-block strong { max-width: 120px; font-size: 11px; }
  .automation-publication-badge { padding: 3px 5px; font-size: 6px !important; }
  .automation-palette-grid { grid-template-columns: 1fr; }
  .automation-phone-screen { height: 430px; }
  .automation-simulator-setup { grid-template-columns: 1fr; }
  .automation-simulator-setup .field,
  .automation-simulator-setup #automation-simulator-payload-wrap,
  .automation-simulator-setup .button { grid-column: 1; }
}

@keyframes automation-sheet-in {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* PontesMol commercial design system */
:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-subtle: #edf2f0;
  --border: #d8e1dd;
  --border-strong: #c6d2cd;
  --text: #14211c;
  --text-muted: #61716a;
  --primary: #12664f;
  --primary-hover: #0c523f;
  --primary-soft: #e6f3ed;
  --blue: #275fac;
  --blue-soft: #edf4ff;
  --orange: #9b581e;
  --orange-soft: #fff6eb;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --shadow: 0 18px 46px rgba(18, 39, 31, 0.09);
  --shadow-soft: 0 5px 18px rgba(18, 39, 31, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 276px;
}

html {
  background: var(--bg);
}

body {
  background:
    radial-gradient(circle at 76% -10%, rgba(18, 102, 79, 0.08), transparent 34%),
    linear-gradient(180deg, #fafcfb 0, var(--bg) 320px),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI Variable", "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(39, 95, 172, 0.18);
  outline-offset: 2px;
}

.sidebar {
  border-right: 0;
  background:
    radial-gradient(circle at 10% 0, rgba(46, 153, 116, 0.15), transparent 27%),
    #0d1d18;
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.05), 16px 0 40px rgba(13, 29, 24, 0.08);
}

.brand {
  min-height: 86px;
  border-bottom-color: rgba(255, 255, 255, 0.08);
  padding: 0 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: linear-gradient(145deg, #20866a, #12664f);
  box-shadow: 0 8px 18px rgba(9, 20, 28, 0.22);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: -0.03em;
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.015em;
}

.brand div > span {
  color: #91a69e;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.nav {
  display: block;
  overflow-y: auto;
  padding: 16px 12px 20px;
}

.nav-item {
  height: 42px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  color: #b8c9c2;
  font-size: 12px;
  font-weight: 600;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.075);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(41, 137, 106, 0.3), rgba(41, 137, 106, 0.12));
  color: #fff;
  box-shadow: inset 3px 0 0 #54c79e, 0 8px 20px rgba(4, 16, 12, 0.12);
}

.setup-progress {
  margin: auto 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 13px 12px;
  background: rgba(255, 255, 255, 0.025);
}

.progress-row {
  min-height: 31px;
}

.status-label {
  max-width: 104px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-link {
  height: 42px;
  margin-inline: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
}

.main {
  background: transparent;
}

.topbar {
  min-height: 86px;
  border-bottom-color: rgba(217, 225, 232, 0.86);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(21, 32, 43, 0.04);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: 22px;
  line-height: 29px;
  letter-spacing: -0.025em;
}

.topbar p {
  max-width: 720px;
  font-size: 12px;
  line-height: 18px;
}

.api-health {
  min-height: 36px;
  border-color: var(--border);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  color: #52606e;
  font-weight: 600;
}

.content {
  width: min(1360px, 100%);
  padding-top: 32px;
}

.notice,
.sync-feedback,
.comment-live-card,
.webhook-summary,
.webhook-automation-cta,
.sticky-actions,
.panel,
.modal,
.automation-topbar,
.chat-workspace,
.automation-builder,
.toggle-field,
.result-box,
.console {
  border-radius: var(--radius);
}

.notice {
  margin-bottom: 22px;
  border-color: #efd3a7;
  background: #fffaf2;
}

.notice strong {
  font-size: 13px;
}

.notice span {
  font-size: 12px;
  line-height: 18px;
}

.section-actions {
  margin-bottom: 22px;
}

.section-heading {
  align-items: center;
  margin-bottom: 18px;
}

.section-heading h2,
.panel-heading h2,
.setup-steps h2 {
  color: #192532;
  font-size: 17px;
  letter-spacing: 0;
}

.section-heading p,
.panel-heading p,
.field > p,
.secret-state,
.guide p {
  font-size: 11px;
  line-height: 17px;
}

.eyebrow,
.section-label,
.automation-kicker,
.automation-pane-label,
.automation-palette-group > small,
.chat-eyebrow {
  letter-spacing: 0.08em;
}

.form-grid {
  gap: 20px 24px;
}

.field label,
.field-label {
  color: #2d3a46;
  font-size: 12px;
}

.field input,
.field select,
.field textarea,
.toolbar select {
  min-height: 42px;
  border-color: #ccd6df;
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13px;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.toolbar select:hover {
  border-color: #b5c2ce;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 107, 85, 0.11);
}

.guide {
  border-left-color: #5f8fd7;
  background: #f2f7ff;
}

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

.page-selection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  border: 1px solid #ccd6df;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.page-selection-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(20, 107, 85, 0.08);
}

.page-selection-item.passive {
  cursor: default;
}

.page-selection-item.passive:hover {
  border-color: #ccd6df;
  box-shadow: none;
}

.page-selection-item span {
  display: grid;
  gap: 3px;
}

.page-selection-item strong {
  font-size: 13px;
}

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

.page-selection-item svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.toggle-field {
  min-height: 74px;
  border-color: var(--border);
  box-shadow: 0 1px 0 rgba(21, 32, 43, 0.03);
}

.switch-track {
  background: #99a8b4;
}

.button {
  min-height: 40px;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 12px;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button.primary {
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(20, 107, 85, 0.18);
}

.button.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 10px 22px rgba(20, 107, 85, 0.22);
}

.button.secondary {
  border-color: #cbd5df;
  background: #fff;
  color: #2f3c49;
  box-shadow: 0 1px 0 rgba(21, 32, 43, 0.03);
}

.button.secondary:hover {
  border-color: #aebbc7;
  background: #f7fafc;
}

.button:disabled,
.button:disabled:hover {
  transform: none;
  box-shadow: none;
}

.icon-button {
  border-radius: var(--radius-sm);
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.icon-button:hover {
  background: #e9eef3;
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

.sticky-actions {
  bottom: 16px;
  border-color: rgba(203, 213, 223, 0.86);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 42px rgba(21, 32, 43, 0.13);
  backdrop-filter: blur(12px);
}

.toolbar {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.segmented {
  border-color: #cbd5df;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 rgba(21, 32, 43, 0.03);
}

.segmented button {
  min-width: 88px;
  font-size: 11px;
}

.segmented button.active {
  background: #e9f2ef;
  color: var(--primary);
}

.work-grid {
  gap: 22px;
}

.panel {
  border-color: #dce3ea;
  box-shadow: 0 8px 26px rgba(21, 32, 43, 0.055);
}

.panel-heading {
  min-height: 44px;
  margin-bottom: 16px;
}

th {
  background: #f8fafc;
  color: #66717e;
  font-size: 10px;
}

td {
  border-bottom-color: #edf1f5;
  color: #33404d;
  font-size: 11px;
  line-height: 17px;
}

tbody tr:hover td {
  background: #fbfcfd;
}

.channel-badge,
.window-chip,
.message-automation-status,
.comment-automation-status,
.automation-status-pill {
  border-radius: 999px;
}

.contact-avatar,
.chat-avatar,
.automation-phone-avatar {
  box-shadow: inset 0 0 0 1px rgba(21, 32, 43, 0.05);
}

.empty-state,
.chat-thread-placeholder,
.automation-inspector-empty,
.automation-phone-empty,
.automation-empty {
  color: #7b8794;
}

.empty-state strong,
.chat-thread-placeholder strong,
.automation-phone-empty strong {
  color: #33404d;
}

.result-box,
.console {
  border-color: #d4dee7;
  background: #f7f9fb;
  font-size: 11px;
}

.console {
  background: #111923;
  color: #dce6ef;
}

.comment-item {
  gap: 10px 16px;
  padding: 15px 2px;
}

.comment-item strong,
.comment-item p {
  font-size: 12px;
}

.comment-live-card {
  border-color: #d7e1e9;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.comment-live-card.ready {
  border-color: #b9d9cb;
  background: #f5fbf8;
}

.comment-live-card.warning {
  border-color: #ecd3ae;
  background: #fffaf2;
}

.webhook-summary {
  border: 1px solid #c9ded5;
  border-left: 4px solid var(--primary);
  background: #f2faf6;
  box-shadow: var(--shadow-soft);
}

.setup-steps ol {
  gap: 14px;
}

.setup-steps li {
  border-top-color: #d8e1e8;
  background: transparent;
}

.setup-steps li > span {
  background: #253443;
}

.webhook-event {
  gap: 18px;
}

.modal-backdrop {
  background: rgba(16, 24, 33, 0.46);
  backdrop-filter: blur(4px);
}

.modal {
  border-color: #d7e0e9;
  box-shadow: 0 26px 70px rgba(10, 18, 28, 0.22);
}

.toast {
  border-color: #d6e0e8;
  border-left-width: 4px;
  border-radius: var(--radius);
  box-shadow: 0 14px 38px rgba(21, 32, 43, 0.15);
}

/* Chat */
.content.chat-content {
  max-width: 1640px;
}

.chat-workspace {
  border-color: #d7e0e8;
  background: #fff;
  box-shadow: 0 18px 48px rgba(21, 32, 43, 0.1);
}

.chat-list-panel,
.chat-context-panel {
  background: #fbfcfd;
}

.chat-pane-heading,
.chat-thread-header {
  border-bottom-color: #dbe3eb;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.chat-search {
  border-color: #d2dce5;
  border-radius: var(--radius-sm);
  background: #fff;
}

.chat-toolbar select,
.chat-compose-tools select,
.chat-button-row input,
.chat-compose-form textarea {
  border-color: #ccd6df;
  border-radius: var(--radius-sm);
  background: #fff;
}

.chat-list {
  padding: 8px;
}

.chat-list-item {
  margin-bottom: 6px;
  border-color: transparent;
  border-radius: var(--radius);
  background: transparent;
}

.chat-list-item:hover {
  border-color: #d8e2ea;
  background: #fff;
}

.chat-list-item.active {
  border-color: #b8d8cc;
  background: #edf8f3;
  box-shadow: 0 8px 20px rgba(20, 107, 85, 0.08);
}

.chat-list-item.active::before {
  background: var(--primary);
}

.chat-thread {
  background-color: #eef3f6;
  background-image: radial-gradient(circle at 1px 1px, rgba(87, 101, 115, 0.08) 1px, transparent 0);
}

.chat-message-bubble {
  border-color: rgba(204, 216, 226, 0.78);
  border-radius: 8px 18px 18px 18px;
  box-shadow: 0 6px 18px rgba(21, 32, 43, 0.07);
}

.chat-message-row.outbound .chat-message-bubble {
  border-color: rgba(125, 179, 158, 0.55);
  background: #dff2e9;
}

.chat-compose-form {
  border-top-color: #dbe4eb;
  background: #fff;
}

.chat-context-content,
.chat-contact-card,
.chat-session-card,
.chat-automation-panel {
  border-color: #dbe4eb;
  border-radius: var(--radius);
  background: #fff;
}

/* Automation */
.content.automation-content {
  padding-top: 18px;
}

.automation-topbar {
  border-color: #d7e0e8;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.automation-builder {
  border-color: #cedbe4;
  background: #eaf0f3;
  box-shadow: 0 20px 52px rgba(21, 32, 43, 0.12);
}

.automation-library,
.automation-studio-panel {
  background: #fbfcfd;
}

.automation-canvas-panel {
  background: #e6edf1;
}

.automation-canvas {
  background-color: #f0f4f6;
  background-image: radial-gradient(circle, #bdcbd4 1px, transparent 1px);
}

.automation-canvas-toolbar,
.automation-validation-summary,
.automation-flow-item,
.automation-palette-grid .automation-palette-group button,
.automation-trigger-card,
.automation-ai-intent-form,
.automation-ai-intent-item,
.automation-phone-shell,
.automation-comment-preview {
  border-radius: var(--radius);
}

.automation-canvas-toolbar {
  border-color: rgba(202, 215, 224, 0.95);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(21, 32, 43, 0.09);
}

.automation-flow-item {
  border-color: transparent;
}

.automation-flow-item:hover {
  border-color: #d7e0e8;
  background: #fff;
}

.automation-flow-item.active {
  border-color: #b7d7ca;
  background: #edf8f3;
  box-shadow: inset 3px 0 #146b55;
}

.automation-palette-grid .automation-palette-group button {
  border-color: #d8e2ea;
  background: #fff;
  box-shadow: 0 1px 0 rgba(21, 32, 43, 0.03);
}

.automation-palette-grid .automation-palette-group button:hover {
  border-color: #b8c7d3;
  background: #f8fafc;
}

.automation-node {
  border-color: #d4dee6;
  border-top-color: var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(21, 32, 43, 0.13);
}

.automation-node.selected {
  box-shadow: 0 0 0 3px rgba(20, 107, 85, 0.15), 0 16px 34px rgba(21, 32, 43, 0.16);
}

.automation-node-header {
  background: #fff;
}

.automation-node-summary,
.automation-node-chips {
  background: #fbfcfd;
}

.automation-studio-tabs {
  border-bottom-color: #dbe4eb;
  background: #f3f6f8;
}

.automation-studio-tabs > button {
  border-radius: var(--radius-sm);
}

.automation-studio-tabs > button.active {
  color: var(--primary);
  box-shadow: 0 3px 10px rgba(21, 32, 43, 0.08);
}

.automation-phone-shell {
  border-color: #14202b;
  background: #14202b;
  box-shadow: 0 20px 46px rgba(21, 32, 43, 0.24);
}

.automation-phone-screen {
  background: #edf4f0;
}

.automation-phone-message > div {
  border-radius: 8px 15px 15px 15px;
}

.automation-phone-message.inbound > div {
  border-radius: 15px 8px 15px 15px;
}

.webhook-automation-cta {
  border-color: #cddfd6;
  background: #f5fbf8;
}

@media (max-width: 980px) {
  .section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .section-heading .button {
    width: auto;
  }

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

@media (max-width: 760px) {
  .topbar {
    min-height: 68px;
    padding: 10px 14px;
  }

  .topbar h1 {
    font-size: 18px;
    line-height: 24px;
  }

  .api-health {
    min-height: 32px;
    padding: 6px 9px;
  }

  .content {
    padding: 18px 14px 42px;
  }

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

  .toolbar,
  .section-actions {
    align-items: stretch;
  }

  .toolbar select,
  .toolbar .button,
  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    min-width: 0;
  }

  .button:hover,
  .icon-button:hover {
    transform: none;
  }

  .sticky-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .save-state {
    padding-left: 0;
  }

  .sticky-actions .button {
    width: 100%;
  }

  .comment-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .comment-item .button {
    grid-row: auto;
    grid-column: 1 / -1;
    width: 100%;
  }

  .webhook-event {
    grid-template-columns: 1fr;
  }

  .setup-steps ol {
    grid-template-columns: 1fr;
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .panel,
  .notice,
  .sync-feedback,
  .comment-live-card,
  .webhook-summary,
  .webhook-automation-cta {
    padding: 14px;
  }

  .section-heading .button,
  .comment-live-actions .button {
    width: 100%;
  }

  .webhook-summary,
  .webhook-automation-cta {
    grid-template-columns: 1fr;
  }

  .callback-value {
    align-items: flex-start;
  }
}
.message-media-link,
.message-delivery-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
}

.message-media-link {
  color: var(--accent, #0b8f62);
  font-weight: 700;
  text-decoration: none;
}

.message-media-link svg {
  width: 0.85rem;
  height: 0.85rem;
}

.message-delivery-meta {
  color: var(--muted, #6b7280);
}
.whatsapp-access-guide {
  border: 1px solid #cbe2d8;
  border-radius: 14px;
  padding: 18px;
  background: linear-gradient(145deg, #f4fbf8, #ffffff);
}

.easy-guide-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.easy-guide-heading h2 {
  margin: 3px 0 0;
}

.easy-guide-heading p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 16px;
}

.whatsapp-access-guide ol {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.whatsapp-access-guide li {
  min-height: 112px;
}

.easy-guide-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.easy-guide-checks span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  background: #e8f5ef;
  color: #24644f;
  font-size: 8px;
  font-weight: 700;
}

.easy-guide-checks svg {
  width: 13px;
  height: 13px;
}

@media (max-width: 900px) {
  .whatsapp-access-guide ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .easy-guide-heading { display: grid; }
  .whatsapp-access-guide ol { grid-template-columns: 1fr; }
}

/* Brand, navigation and integration center */
.brand-copy {
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(190px, calc(100% - 38px));
  height: auto;
  max-height: 42px;
  object-fit: contain;
  object-position: left center;
  flex: 0 1 auto;
}

.sidebar-close,
.sidebar-backdrop {
  display: none;
}

.nav-label {
  display: block;
  margin: 18px 12px 8px;
  color: #708980;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav-label:first-child {
  margin-top: 3px;
}

.nav-item svg {
  width: 17px;
  height: 17px;
}

.nav-item.active svg {
  color: #78dbb7;
}

.section-label {
  letter-spacing: 0.11em;
}

.topbar-eyebrow {
  display: block;
  margin-bottom: 1px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.integration-overview {
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  background:
    radial-gradient(circle at 92% 0, rgba(18, 102, 79, 0.09), transparent 35%),
    var(--surface);
  box-shadow: var(--shadow-soft);
}

.integration-overview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.integration-overview-heading h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.integration-overview-heading p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 18px;
}

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

.integration-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border: 1px solid #dce5e1;
  border-radius: 13px;
  padding: 13px;
  background: rgba(249, 251, 250, 0.9);
  color: inherit;
  text-decoration: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.integration-card:hover {
  border-color: #a9c9bc;
  background: #fff;
  box-shadow: 0 10px 24px rgba(18, 65, 48, 0.08);
  transform: translateY(-2px);
}

.integration-card.ready {
  border-color: #c8e3d8;
  background: #f7fcf9;
}

.integration-card.error {
  border-color: #edc9c4;
  background: #fff9f8;
}

.integration-card > span:nth-child(2) {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.integration-card strong {
  font-size: 12px;
}

.integration-card small {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-card-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.integration-card-icon svg {
  width: 17px;
  height: 17px;
}

.integration-card-icon.instagram { background: #faedf3; color: #b33f70; }

.meta-onboarding {
  margin: 1.5rem 0 2rem;
  padding: 1.5rem;
  border: 1px solid var(--border, #dce5e1);
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #f5faf8);
}

.meta-onboarding-heading,
.meta-asset-picker-actions,
.meta-account-card header,
.meta-account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.meta-onboarding-heading h2,
.meta-asset-picker h3 { margin: .2rem 0; }
.meta-onboarding-heading p,
.meta-asset-picker p { margin: 0; color: var(--muted, #66756f); }
.meta-onboarding-actions,
.meta-account-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.meta-account-grid { display: grid; gap: 1rem; margin-top: 1.25rem; }

.meta-empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .4rem;
  text-align: center;
  color: var(--muted, #66756f);
  border: 1px dashed var(--border, #cddbd5);
  border-radius: 14px;
}

.meta-empty-state svg { width: 28px; height: 28px; }
.meta-account-card { border: 1px solid var(--border, #dce5e1); border-radius: 14px; background: #fff; overflow: hidden; }
.meta-account-card header { padding: 1rem; background: #f7faf9; }
.meta-account-card header > div,
.meta-account-row > div:first-child,
.meta-account-row > div:first-child > span { display: flex; gap: .65rem; }
.meta-account-card header > div,
.meta-account-row > div:first-child > span { flex-direction: column; gap: .15rem; }
.meta-account-status { font-size: .78rem; color: var(--muted, #66756f); }
.meta-account-row { padding: .9rem 1rem; border-top: 1px solid var(--border, #edf1ef); }
.meta-account-row > div:first-child { align-items: center; min-width: 0; }
.meta-account-row small { color: var(--muted, #66756f); overflow-wrap: anywhere; }
.meta-account-card.status-attention { border-color: #d9a441; }
.meta-account-card.status-disconnected { opacity: .72; }

.meta-asset-picker { margin-top: 1.25rem; padding: 1.25rem; border-radius: 14px; background: #fff; border: 1px solid var(--border, #dce5e1); }
.meta-asset-list { display: grid; gap: .65rem; margin: 1rem 0; }
.meta-asset-option { display: flex; align-items: center; gap: .8rem; padding: .85rem; border: 1px solid var(--border, #dce5e1); border-radius: 12px; cursor: pointer; }
.meta-asset-option > span { display: flex; flex-direction: column; gap: .2rem; }
.meta-asset-option small { color: var(--muted, #66756f); }
.icon-button.danger { color: #a33a3a; }
.oauth-callback-page { min-height: 100vh; display: grid; place-items: center; background: #f3f7f5; }
.oauth-callback-card { padding: 2rem; text-align: center; background: #fff; border-radius: 18px; box-shadow: 0 18px 60px rgb(20 50 40 / 12%); }
.production-mode .legacy-social-setup,
.production-mode .technical-setup-only { display: none !important; }

@media (max-width: 760px) {
  .meta-onboarding-heading,
  .meta-account-row { align-items: stretch; flex-direction: column; }
  .meta-onboarding-actions .button { flex: 1; }
}
.integration-card-icon.facebook { background: #eaf1fd; color: #2864b8; }
.integration-card-icon.whatsapp { background: #e7f6ee; color: #118354; }
.integration-card-icon.webhook { background: #f2edfb; color: #7251a4; }

#view-configuration > .notice {
  margin-bottom: 22px;
}

#config-form > .section-heading {
  scroll-margin-top: 106px;
  margin: 24px 0 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  padding: 22px 22px 18px;
  background: var(--surface);
}

#config-form > .section-heading + .form-grid {
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  padding: 0 22px 22px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

#config-form > .divider {
  display: none;
}

#config-form > .whatsapp-access-guide {
  margin-top: 14px;
}

.panel,
.comment-live-card,
.webhook-summary,
.webhook-automation-cta,
.setup-steps,
.automation-topbar,
.automation-builder,
.chat-workspace {
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

.toolbar {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.table-wrap {
  border-radius: 0 0 14px 14px;
}

th {
  background: #f5f8f7;
  color: #52645c;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f6faf8;
}

.chat-pane-heading strong,
.chat-thread-placeholder strong {
  font-family: inherit;
}

.chat-workspace {
  border-radius: 18px;
  box-shadow: 0 22px 54px rgba(18, 52, 39, 0.11);
}

.chat-list-item.active {
  background: #e8f4ee;
  box-shadow: inset 3px 0 var(--primary);
}

.automation-pane-label,
.automation-palette-group > small,
.automation-property-group h3,
.chat-context-label,
.automation-inline-heading span {
  font-size: 9px;
}

.automation-node-summary,
.automation-help,
.automation-run-logs span,
.automation-status-pill {
  font-size: 9px;
}

.automation-flow-item strong,
.automation-palette-grid button,
.automation-inspector-content .field label {
  font-size: 10px;
}

.modal-backdrop {
  backdrop-filter: blur(5px);
}

.modal {
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
}

@media (max-width: 1080px) {
  .integration-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .automation-topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .automation-actions {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
  }

  .automation-actions .button {
    min-width: 0;
    flex: 1 1 126px;
  }

  .automation-builder {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  body.nav-open {
    overflow: hidden;
  }

  .sidebar {
    z-index: 60;
    width: min(304px, 88vw);
  }

  .sidebar-close {
    display: inline-grid;
    margin-left: auto;
    color: #c0cec8;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    border: 0;
    background: rgba(8, 20, 16, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .automation-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .automation-actions .button {
    width: 100%;
    min-width: 0;
  }

  .automation-builder {
    height: calc(100dvh - 257px);
    min-height: 480px;
  }

  .content.chat-content {
    height: calc(100dvh - 68px);
  }

  .chat-workspace {
    height: calc(100dvh - 68px);
    max-height: calc(100dvh - 68px);
    overflow: hidden;
  }

  .chat-list-panel,
  .chat-thread-panel {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .topbar-eyebrow {
    display: none;
  }

  .integration-overview {
    padding: 18px;
  }

  .integration-overview-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 16px;
  }

  .integration-overview-heading .button {
    width: 100%;
  }

  #config-form > .section-heading {
    padding: 18px 18px 14px;
  }

  #config-form > .section-heading + .form-grid {
    padding: 0 18px 18px;
  }
}

@media (max-width: 520px) {
  .integration-card-grid {
    grid-template-columns: 1fr;
  }

  .integration-card {
    padding: 11px;
  }

  .integration-overview-heading h2 {
    font-size: 18px;
  }

  .api-health {
    width: 32px;
    justify-content: center;
    padding: 0;
  }
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 33, 0.58);
  backdrop-filter: blur(5px);
}

.auth-modal.hidden { display: none; }

.auth-card {
  display: grid;
  width: min(390px, 100%);
  gap: 14px;
  border: 1px solid #d7e0e8;
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(16, 24, 33, 0.24);
}

.auth-card h2 { margin: 0; font-size: 20px; line-height: 28px; }
.auth-card p { margin: -6px 0 4px; color: var(--text-muted); font-size: 13px; }
.auth-card label { display: grid; gap: 7px; color: var(--text); font-size: 12px; font-weight: 700; }
.auth-card input { width: 100%; }
.auth-icon {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #e7f3ed;
  color: var(--accent);
}
.auth-error { min-height: 18px; color: var(--danger); font-size: 12px; }

[data-legacy-admin-api-key].legacy-disabled {
  opacity: 0.72;
}

body.reviewer-mode [data-legacy-admin-api-key] {
  display: none;
}

/* Administrative feeds: keep dense data readable without squeezing the page. */
#view-messages > .messages-work-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

#view-messages > .messages-work-grid > .panel:first-child {
  overflow: hidden;
}

#view-messages #send-message-form {
  grid-template-columns: minmax(150px, .55fr) minmax(210px, .9fr) minmax(280px, 1.55fr);
  align-items: start;
}

#view-messages #send-message-form > .panel-heading,
#view-messages #send-message-form > .message-reply-context,
#view-messages #send-message-form > #send-whatsapp-template-wrap,
#view-messages #send-message-form > #send-result,
#view-messages #send-message-form > button[type="submit"] {
  grid-column: 1 / -1;
}

#view-messages #send-message-form .message-compose-text {
  grid-column: 3;
}

#view-messages #send-text {
  min-height: 132px;
}

#view-webhook > .webhook-summary,
#view-webhook > .webhook-automation-cta {
  margin-bottom: 16px;
}

#view-webhook > .webhook-summary {
  min-height: 86px;
  border: 1px solid #c9ded5;
  border-left: 4px solid var(--primary);
  border-radius: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #f0faf5, #ffffff);
}

#view-webhook > .webhook-automation-cta {
  margin-top: 0;
  border-radius: 16px;
}

#view-webhook .webhook-events-panel {
  overflow: hidden;
  margin-top: 16px;
}

#view-webhook .webhook-event-list {
  gap: 12px;
}

#view-webhook .webhook-event {
  grid-template-columns: minmax(180px, .34fr) minmax(0, 1fr);
  gap: 18px;
  border: 1px solid #d9e4df;
  border-radius: 14px;
  padding: 14px;
  background: #fbfdfc;
}

#view-webhook .webhook-event-summary {
  padding: 5px 2px;
}

#view-webhook .webhook-event .console {
  width: 100%;
  min-width: 0;
  min-height: 150px;
  max-height: 300px;
  border-color: #263541;
  border-radius: 10px;
  font-size: 10px;
}

@media (max-width: 760px) {
  #view-messages #send-message-form {
    grid-template-columns: 1fr;
  }

  #view-messages #send-message-form .message-compose-text,
  #view-messages #send-message-form > .panel-heading,
  #view-messages #send-message-form > .message-reply-context,
  #view-messages #send-message-form > #send-whatsapp-template-wrap,
  #view-messages #send-message-form > #send-result,
  #view-messages #send-message-form > button[type="submit"] {
    grid-column: auto;
    grid-row: auto;
  }

  #view-messages .messages-table {
    min-width: 860px;
  }

  #view-webhook .webhook-event {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  #view-messages .messages-table {
    min-width: 760px;
  }

  #view-webhook > .webhook-summary {
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
