:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #e6e9f1;
  --rail: #ffffff;
  --nav: #fbfcff;
  --blue: #2f6bff;
  --blue-soft: #eaf0ff;
  --green: #16a34a;
  --purple: #7c3aed;
  --orange: #f97316;
  --red: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
p { color: var(--muted); line-height: 1.5; }
h1, h2, h3 { margin: 0; letter-spacing: 0; }
.boot { padding: 40px; color: var(--muted); }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: radial-gradient(circle at top left, #eaf0ff 0, transparent 32%), var(--bg);
}
.login-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.app-frame {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 38px 230px minmax(0, 1fr);
  background: var(--bg);
}
.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 8px 5px;
}
.rail-logo, .rail-item {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: transparent;
  color: #344054;
  font-size: 10px;
  font-weight: 900;
}
.rail-logo {
  color: var(--blue);
  border: 1px solid #c7d7ff;
  background: #fff;
}
.rail-item.active, .rail-item:hover {
  background: var(--blue);
  color: #fff;
}
.rail-stack { display: grid; gap: 10px; justify-items: center; }
.rail-bottom { align-self: end; }

.workspace-menu {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--nav);
  border-right: 1px solid var(--line);
}
.workspace-head {
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  font-size: 12px;
  font-weight: 900;
}
.brand strong { display: block; font-size: 14px; }
.brand span, .muted { color: var(--muted); }
.workspace-head label {
  display: block;
  margin-bottom: 6px;
  color: #475467;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.tenant-select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.grouped-nav {
  overflow: auto;
  padding: 10px 8px 18px;
}
.nav-section {
  display: grid;
  gap: 2px;
  margin-bottom: 14px;
}
.nav-section h3 {
  padding: 8px 10px 5px;
  color: #98a2b3;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}
.nav-section button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: #344054;
  text-align: left;
  font-size: 13px;
}
.nav-section button:hover, .nav-section button.active {
  background: #edf3ff;
  color: #1749d6;
}
.nav-section b {
  min-width: 20px;
  color: #667085;
  font-size: 11px;
  text-align: right;
}
.workspace-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.workspace-user strong { display: block; font-size: 12px; }
.workspace-user span { display: block; max-width: 150px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.main {
  min-width: 0;
  padding: 20px;
  overflow: auto;
}
.inbox-frame .main {
  padding: 0;
  overflow: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.inbox-frame .topbar { display: none; }
.topbar h1 { font-size: 24px; }
.topbar p { margin: 4px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 10px;
  color: #155eef;
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 16px; align-items: start; }
.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 460px);
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
  padding: 24px;
  color: #fff;
  border-radius: 18px;
  background: linear-gradient(135deg, #1d2939, #155eef 55%, #7c3aed);
  box-shadow: var(--shadow);
}
.hero-panel h2 { max-width: 780px; font-size: clamp(25px, 3vw, 38px); line-height: 1.08; }
.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: #155eef;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 900;
}
.hero-panel .eyebrow { color: #d9e4ff; }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.metric-strip div {
  padding: 12px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 14px;
  background: rgba(255,255,255,.12);
}
.metric-strip span { display: block; color: #e6edff; font-size: 12px; }
.metric-strip strong { display: block; margin-top: 5px; font-size: 22px; }
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .05);
}
.card strong { display: block; margin-top: 8px; font-size: 28px; }
.panel { margin-bottom: 16px; }
.panel.compact { padding: 12px 14px; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.module-card {
  min-height: 148px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.module-card:hover {
  border-color: #b9c9ff;
  box-shadow: 0 0 0 4px #edf3ff;
}
.module-card span { color: #155eef; font-size: 12px; font-weight: 900; text-transform: uppercase; }
.module-card strong { display: block; margin: 10px 0 6px; font-size: 19px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row.inset { margin-top: 12px; }
.toolbar-search, .conversation-search { width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { color: #344054; font-size: 13px; font-weight: 750; }
input, select, textarea {
  min-width: 0;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
textarea { min-height: 112px; resize: vertical; }
.primary, .ghost, .danger, .tiny {
  border-radius: 12px;
  font-weight: 800;
}
.primary { padding: 10px 14px; color: #fff; background: var(--blue); }
.ghost { padding: 10px 14px; color: #155eef; background: #edf3ff; }
.danger { padding: 10px 14px; color: var(--red); background: #fee2e2; }
.tiny { padding: 7px 10px; color: #155eef; background: #edf3ff; }
.mini-icon, .icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #344054;
  background: #f2f4f7;
  font-weight: 900;
}
.icon-button { font-size: 22px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: #667085; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  color: #155eef;
  background: #edf3ff;
  font-size: 11px;
  font-weight: 900;
}
.badge.warn { color: #b45309; background: #ffedd5; }
.badge.bad { color: #b42318; background: #fee4e2; }
.danger-text { color: var(--red); }
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}

.respond-inbox {
  height: 100vh;
  display: grid;
  grid-template-columns: 170px 260px minmax(0, 1fr) 44px;
  background: #fff;
}
.inbox-filter-panel {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcff;
}
.inbox-title {
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.inbox-title h2 { font-size: 14px; }
.inbox-filter-group {
  display: grid;
  gap: 1px;
  padding: 8px 8px 4px;
}
.inbox-filter-group h3 {
  margin: 8px 4px 4px;
  color: #667085;
  font-size: 11px;
  font-weight: 900;
}
.inbox-filter-group button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  color: #475467;
  background: transparent;
  border-radius: 10px;
  font-size: 12px;
}
.inbox-filter-group button:hover { color: #155eef; background: #edf3ff; }

.conversation-list-panel {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 50px 38px 42px minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: #fff;
}
.list-tabs {
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.list-tabs button {
  height: 50px;
  color: #475467;
  background: transparent;
  border-bottom: 2px solid transparent;
  font-weight: 850;
}
.list-tabs button.active { color: #155eef; border-color: #155eef; }
.list-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: #475467;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.list-tools label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; }
.conversation-search {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
}
.conversation-feed { min-width: 0; overflow: auto; }
.conversation-card {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  text-align: left;
  background: #fff;
  border-bottom: 1px solid #f0f2f6;
}
.conversation-card:hover, .conversation-card.active { background: #edf3ff; }
.conversation-card-body { min-width: 0; }
.conversation-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.conversation-card strong, .conversation-card p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-card p { margin: 4px 0; color: #475467; font-size: 12px; }
.conversation-card small { color: #667085; font-size: 10px; white-space: nowrap; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; color: #667085; }
.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #2f6bff, #7c3aed);
  font-size: 12px;
  font-weight: 900;
}
.avatar.small { width: 32px; height: 32px; font-size: 11px; }
.avatar.large { width: 44px; height: 44px; }
.avatar.whatsapp { background: linear-gradient(135deg, #16a34a, #22c55e); }
.avatar.website_chat { background: linear-gradient(135deg, #2f6bff, #06b6d4); }

.thread-panel {
  min-width: 0;
  background: #f8f9fd;
}
.thread-workspace {
  height: 100vh;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
}
.thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.thread-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thread-person h2 { font-size: 15px; }
.thread-badges, .thread-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.thread-actions .ghost { padding: 8px 10px; }
.thread-body { min-width: 0; overflow: auto; padding: 18px 12px; }
.thread-timeline { max-width: 780px; margin: 0 auto; }
.event-card {
  margin: 10px auto 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
.event-card p { margin: 4px 0 0; font-size: 12px; }
.chat-row { display: flex; margin: 10px 0; }
.chat-row.outbound { justify-content: flex-end; }
.message-bubble {
  max-width: min(620px, 82%);
  padding: 9px 11px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(15, 23, 42, .04);
}
.chat-row.outbound .message-bubble {
  background: #eef2ff;
  border-color: #dbe4ff;
}
.message-bubble small { display: block; margin-bottom: 4px; color: #667085; font-size: 10px; }
.message-bubble span { display: block; color: #344054; font-size: 13px; line-height: 1.45; }
.internal-note-strip {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.internal-note-strip div {
  padding: 10px 12px;
  border: 1px solid #f2d8a8;
  border-radius: 12px;
  background: #fff7ed;
}
.internal-note-strip p { margin: 4px 0 0; font-size: 12px; }
.composer {
  display: grid;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.composer-channel {
  width: fit-content;
  padding: 4px 8px;
  color: #155eef;
  background: #edf3ff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}
.composer form { display: grid; gap: 8px; }
.composer textarea {
  min-height: 76px;
  border-radius: 14px;
  background: #fffdf8;
}
.composer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.composer-actions label { margin-right: auto; font-weight: 650; }
.thread-tool-rail {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px 5px;
  border-left: 1px solid var(--line);
  background: #fff;
}
.thread-tool-rail button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #155eef;
  background: #fff;
  font-weight: 900;
}

.profile-list {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 10px;
  font-size: 13px;
}
.profile-list.wide {
  grid-template-columns: 140px 1fr;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
}
.profile-list span { color: var(--muted); }
.profile-list strong { overflow-wrap: anywhere; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.notes-list { max-height: 190px; overflow: auto; margin-bottom: 8px; }
.subpanel { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.stack-card { margin-bottom: 12px; }
.note {
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}
.note p { margin: 4px 0 0; }
.code {
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: #eaf0ff;
  background: #111827;
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.workflow-builder { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr); gap: 16px; align-items: start; }
.json-area { min-height: 300px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.step-library { display: grid; gap: 8px; }
.step-chip {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}
.step-chip strong { display: block; }
.step-chip code { color: #155eef; }
.stage-list { display: grid; gap: 10px; }
.stage-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcff;
}
.stage-row > span:first-child { width: 12px; height: 12px; border-radius: 999px; }
.success-panel { border-color: #c2eada; background: #f0fdf4; }
.empty-state {
  margin: 14px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfcff;
}
.empty-state.big { margin: 40px; padding: 50px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(14px);
}
.modal-panel {
  width: min(840px, 100%);
  max-height: min(88vh, 820px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 32px 90px rgba(15, 23, 42, .28);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f7f9ff);
}
.modal-body { overflow: auto; padding: 22px; }
.modal-body textarea { min-height: 150px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  padding: 12px 14px;
  color: #fff;
  background: #111827;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .app-frame { grid-template-columns: 38px 210px minmax(0, 1fr); }
  .respond-inbox { grid-template-columns: 220px minmax(0, 1fr) 40px; }
  .inbox-filter-panel { display: none; }
}

@media (max-width: 860px) {
  .app-frame { grid-template-columns: 1fr; }
  .rail { display: none; }
  .workspace-menu { position: static; }
  .main { padding: 14px; }
  .inbox-frame .main { padding: 0; }
  .grid, .split, .form-grid, .hero-panel, .module-grid, .workflow-builder { grid-template-columns: 1fr; }
  .respond-inbox { height: auto; min-height: 100vh; grid-template-columns: 1fr; }
  .conversation-list-panel { min-height: 420px; }
  .thread-tool-rail { display: none; }
  .thread-workspace { height: auto; min-height: 100vh; }
  .thread-header { align-items: flex-start; flex-direction: column; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 12px; align-items: end; }
  .modal-panel { max-height: 92vh; border-radius: 20px 20px 0 0; }
}
