:root {
  color-scheme: light;
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --text: #17211f;
  --muted: #66736f;
  --line: #dce5e1;
  --brand: #168a63;
  --brand-dark: #0c694c;
  --blue: #135f7d;
  --gold: #c99a3d;
  --accent: #2457a6;
  --warning: #b56a17;
  --danger: #bd3a35;
  --shadow: 0 18px 45px rgba(19, 36, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(360px, 440px);
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: clamp(22px, 3.2vw, 42px) clamp(36px, 7vw, 96px);
  min-height: 100vh;
  padding: clamp(28px, 5vw, 58px) clamp(28px, 6vw, 70px) 78px;
  background:
    linear-gradient(135deg, rgba(19, 95, 125, 0.92), rgba(18, 35, 31, 0.88)),
    radial-gradient(circle at 15% 15%, rgba(201, 154, 61, 0.28), transparent 34%),
    var(--blue);
}

.login-hero-title {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: baseline;
  gap: 18px;
  max-width: 900px;
  color: #ffffff;
  text-align: center;
  white-space: nowrap;
  font-size: clamp(1.36rem, 2.18vw, 2.04rem);
  font-weight: 800;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45)) drop-shadow(0 0 10px rgba(232, 255, 249, 0.25));
}

.login-hero-title strong {
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}

.login-hero-title span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
}

.login-hero-title strong,
.login-hero-title span {
  background: linear-gradient(90deg, #1aa8a3 0%, #22c55e 45%, #2dd4bf 72%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-brand-panel {
  display: grid;
  align-content: center;
  gap: 28px;
  justify-items: center;
  color: #ffffff;
}

.login-caran-logo,
.login-zapflow-logo {
  width: min(340px, 100%);
  height: auto;
  border-radius: 4px;
  background: #ffffff;
  padding: 12px;
}

.login-zapflow-logo {
  margin-top: 0;
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 2.15rem;
  line-height: 1.05;
  letter-spacing: 0;
}

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

.login-hint {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.login-hint span {
  color: var(--muted);
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: center;
}

.login-footer {
  position: absolute;
  right: 24px;
  bottom: 16px;
  left: 24px;
  color: rgba(226, 242, 237, 0.82);
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  min-height: 0;
  padding: 24px;
  background: #12231f;
  color: #f4fffb;
  overflow: hidden;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand-logo {
  width: min(190px, 100%);
  height: auto;
  border-radius: 4px;
  background: #ffffff;
  padding: 8px;
}

.sidebar-zapflow-logo {
  display: block;
  width: 100%;
  max-width: 258px;
  height: auto;
  margin-top: auto;
  border-radius: 4px;
  background: #ffffff;
  padding: 8px;
}

.settings-watermark {
  display: block;
  position: absolute;
  top: 58px;
  right: 28px;
  width: min(260px, 42vw);
  opacity: 0.16;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.brand span,
.sidebar-footer span {
  display: block;
  color: #a9bbb5;
  font-size: 0.86rem;
}

.nav-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-list::-webkit-scrollbar {
  width: 6px;
}

.nav-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.nav-item.settings-only-nav {
  display: none;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.nav-item strong {
  display: none;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

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

.workspace-footer {
  position: fixed;
  right: 24px;
  bottom: 0;
  left: 304px;
  z-index: 15;
  margin-top: 0;
  border-top: 1px solid rgba(207, 218, 214, 0.78);
  padding: 8px 0 10px;
  background: rgba(238, 242, 241, 0.94);
  backdrop-filter: blur(8px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: -24px -24px 18px;
  border-bottom: 1px solid rgba(207, 218, 214, 0.78);
  padding: 24px 24px 16px;
  background: rgba(238, 242, 241, 0.96);
  backdrop-filter: blur(8px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

h2 {
  font-size: 1.05rem;
}

.topbar p,
.panel-header span,
.chat-meta,
.agent-card span,
.user-card span,
.template-card span,
.client-card span,
.bulk-row span,
.integration-panel li,
.api-note span,
.muted-copy {
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-layout {
  align-items: start;
}

.dashboard-panel {
  display: grid;
  gap: 14px;
}

.dashboard-template-field {
  display: grid;
  gap: 6px;
}

.dashboard-template-field > span {
  color: var(--muted);
  font-weight: 700;
}

.dashboard-template-picker {
  position: relative;
}

.dashboard-template-picker > summary {
  min-height: 42px;
  padding: 10px 34px 10px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
  list-style: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-template-picker > summary::-webkit-details-marker {
  display: none;
}

.dashboard-template-picker > summary::after {
  position: absolute;
  top: 13px;
  right: 13px;
  content: "▾";
}

.dashboard-template-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  display: grid;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(16 35 31 / 16%);
}

.dashboard-template-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.dashboard-template-option:hover {
  background: #edf7f3;
}

.dashboard-template-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.dashboard-template-option span {
  overflow-wrap: anywhere;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
}

.dashboard-metric-card,
.dashboard-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.dashboard-metric-card {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 14px;
}

.dashboard-metric-card span,
.dashboard-metric-card small,
.dashboard-chart-header span,
.dashboard-origin-row span,
.dashboard-bar-item small {
  color: var(--muted);
}

.dashboard-metric-card strong {
  font-size: 1.9rem;
  line-height: 1;
}

.dashboard-campaign-panel {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.dashboard-campaign-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.dashboard-campaign-header span {
  color: var(--muted);
}

.dashboard-campaign-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}

.dashboard-quality-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.dashboard-quality-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-quality-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.dashboard-quality-header span,
.dashboard-quality-tag span {
  color: var(--muted);
}

.dashboard-quality-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.dashboard-quality-tag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.dashboard-quality-tag div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-quality-tag strong,
.dashboard-quality-tag span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-quality-tag b {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.dashboard-quality-tag.quality-green b {
  color: #047857;
  background: #d1fae5;
}

.dashboard-quality-tag.quality-yellow b {
  color: #92400e;
  background: #fef3c7;
}

.dashboard-quality-tag.quality-red b {
  color: #b91c1c;
  background: #fee2e2;
}

.dashboard-quality-tag.quality-neutral b {
  color: #52615d;
  background: #e5ebe8;
}

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

.dashboard-chart-card {
  display: grid;
  gap: 14px;
  min-height: 180px;
  padding: 16px;
}

.dashboard-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.dashboard-chart-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.dashboard-chart-header strong {
  color: var(--brand-dark);
  font-size: 2rem;
  line-height: 1;
}

.dashboard-progress {
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe9e5;
}

.dashboard-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-dark), #22c55e);
}

.dashboard-bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(38px, 1fr);
  align-items: end;
  gap: 8px;
  min-height: 170px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.dashboard-bar-item {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 38px;
}

.dashboard-bar {
  display: block;
  width: 100%;
  max-width: 34px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #18a886, var(--blue));
}

.dashboard-origin-list {
  display: grid;
  gap: 10px;
}

.dashboard-origin-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(140px, 2fr) 48px;
  gap: 10px;
  align-items: center;
}

.dashboard-response-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.dashboard-response-header,
.dashboard-response-detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-response-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.dashboard-response-header span,
.dashboard-response-detail-title span,
.dashboard-response-card small,
.dashboard-response-table-row span {
  color: var(--muted);
}

.dashboard-response-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.dashboard-response-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 10px;
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.dashboard-response-card:hover,
.dashboard-response-card.active {
  border-color: var(--brand);
  background: #ecf8f3;
}

.dashboard-response-card span {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-response-card strong {
  grid-row: span 2;
  align-self: center;
  font-size: 1.7rem;
}

.dashboard-response-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-response-detail {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.dashboard-response-table {
  display: grid;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.dashboard-response-table-head,
.dashboard-response-table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(145px, .8fr) minmax(145px, .8fr) minmax(150px, auto);
  gap: 12px;
  align-items: center;
  min-width: 740px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}

.dashboard-response-table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f1;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dashboard-response-table-row:last-child {
  border-bottom: 0;
}

.dashboard-response-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.dashboard-response-actions button {
  min-width: 68px;
  white-space: nowrap;
}

#inboxView.active {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 134px);
  min-height: 560px;
  overflow: hidden;
}

.conversation-list-panel,
.chat-panel,
.form-panel,
.table-panel,
.integration-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.conversation-list-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

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

.chat-header {
  padding-right: 138px;
}

.chat-insight-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.competitor-insight-button,
.vehicle-insight-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #d99b27;
  border-radius: 6px;
  color: #6b4300;
  background: #fff4d6;
  font-weight: 800;
}

.ai-agent-status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid #8bcab5;
  border-radius: 999px;
  color: #0f5d48;
  background: #e7f5ef;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.ai-agent-status-tag.test,
.ai-agent-status-tag.disabled {
  border-color: #b8c1be;
  color: #52605c;
  background: #f0f3f2;
}

.ai-agent-status-tag.assisted,
.ai-agent-status-tag.supervised,
.ai-agent-status-tag.observe {
  border-color: #d99b27;
  color: #6b4300;
  background: #fff4d6;
}

.vehicle-insight-button {
  border-color: #6cae98;
  color: #0f5d48;
  background: #e7f5ef;
}

.panel-header select {
  max-width: 190px;
}

.inbox-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inbox-icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--text);
}

.inbox-icon-button:hover,
.inbox-icon-button[aria-pressed="true"] {
  border-color: var(--green);
  background: #e5f7ef;
  color: var(--green-dark);
}

.inbox-icon-button img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.inbox-icon-button.recent img {
  width: 28px;
  height: 28px;
}

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

.template-panel-actions {
  align-items: center;
  flex-wrap: nowrap;
}

.template-panel-actions select {
  min-width: 180px;
}

.template-panel-actions .ghost-action {
  min-height: 40px;
  white-space: nowrap;
}

.compact-filters {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(140px, 170px);
  gap: 8px;
}

.compact-filters input {
  min-height: 40px;
}

.search-box {
  display: grid;
  gap: 6px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 0.86rem;
}

.inbox-filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px 14px;
}

.inbox-filter-row .search-box {
  min-width: 0;
  padding: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 138, 99, 0.14);
}

.conversation-list {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  gap: 6px;
  padding: 0 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.conversation-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 54px;
  padding: 7px 9px;
  background: var(--surface-2);
  text-align: left;
  overflow: hidden;
}

.conversation-item.active {
  border-color: var(--brand);
  background: #edf8f3;
}

.conversation-item.waiting {
  border-color: #f0bc55;
  background: #fff8eb;
}

.conversation-item.waiting.active {
  border-color: var(--warning);
  background: #fff1d8;
}

.conversation-title,
.chat-title,
.agent-title,
.user-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.conversation-title,
.conversation-summary {
  min-width: 0;
}

.conversation-markers {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  align-items: center;
  max-width: 186px;
  min-width: 0;
}

.conversation-markers .account-tag {
  max-width: 158px;
}

.conversation-markers .handoff-account-tag {
  max-width: 176px;
}

.chat-title-markers {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.chat-title-markers .account-tag {
  max-width: 150px;
}

.conversation-template-sticker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: contain;
}

.conversation-title strong,
.chat-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title strong {
  font-size: 0.9rem;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 0.71rem;
  font-weight: 700;
}

.badge.open {
  background: #dcf5e9;
  color: var(--brand-dark);
}

.badge.waiting {
  background: #fff0d7;
  color: var(--warning);
}

.badge.forwarded {
  background: #e7effd;
  color: var(--accent);
}

.badge.closed {
  background: #eceff1;
  color: #59646a;
}

.account-tag {
  display: inline-flex;
  width: fit-content;
  max-width: 124px;
  min-width: 0;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--tag-color), #000 12%);
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--tag-color), #fff 86%);
  color: color-mix(in srgb, var(--tag-color), #000 45%);
  font-size: 0.72rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted-account {
  color: #536268;
}

.conversation-summary {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  align-items: center;
}

.conversation-status-line {
  min-height: 22px;
}

.conversation-phone {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-meta-window {
  display: block;
  width: fit-content;
  margin-top: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.chat-meta-window.open {
  background: #dcf5e9;
  color: var(--brand-dark);
}

.chat-meta-window.closed {
  background: #fff0d7;
  color: var(--warning);
}

.message-thread {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  background:
    linear-gradient(rgba(255,255,255,0.88), rgba(255,255,255,0.88)),
    repeating-linear-gradient(45deg, #dfe9e5 0 1px, transparent 1px 18px);
}

.message-thread::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--zapflow-watermark-image, url("assets/zapflow-logo.svg")) center / min(44%, 420px) auto no-repeat;
  content: "";
  opacity: 0.075;
  pointer-events: none;
}

.message-thread > * {
  position: relative;
  z-index: 1;
}

.retake-alert {
  display: grid;
  width: min(460px, 100%);
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #ffc9c0;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff1ef;
  color: #40201a;
}

.retake-alert.waiting-response-alert {
  grid-template-columns: 28px minmax(0, 1fr);
  border-color: #f0bc55;
  background: #fff8eb;
  color: #6f4700;
}

.retake-alert.waiting-response-alert svg {
  stroke: var(--warning);
}

.retake-alert svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--danger);
  stroke-width: 2;
}

.retake-alert p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.25;
}

.retake-alert button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #15231f;
  color: #fff;
  font-weight: 800;
  line-height: 1.05;
  cursor: pointer;
}

.message-thread::-webkit-scrollbar {
  width: 10px;
}

.message-thread::-webkit-scrollbar-track {
  background: rgba(223, 233, 229, 0.7);
}

.message-thread::-webkit-scrollbar-thumb {
  border: 2px solid rgba(223, 233, 229, 0.7);
  border-radius: 999px;
  background: #9ab4aa;
}

.conversation-history-divider {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.conversation-history-divider::before,
.conversation-history-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.conversation-history-divider.current {
  color: var(--brand-dark);
}

.message {
  max-width: min(680px, 82%);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(19, 36, 32, 0.08);
  line-height: 1.45;
}

.message.agent {
  align-self: flex-end;
  background: #dcf5e9;
}

.template-sticker {
  display: block;
  width: 34px;
  height: 34px;
  margin: -2px 0 8px auto;
  border-radius: 50%;
  object-fit: contain;
}

.message-media-link {
  display: block;
  width: fit-content;
  max-width: 100%;
}

.message-document-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid #c9d9d4;
  border-radius: 8px;
  background: #f6f8f7;
  color: #0f4f4f;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.message-document-link:hover {
  border-color: #168a63;
  color: #0b6b4c;
}

.message-media {
  display: block;
  width: auto;
  max-width: min(320px, 100%);
  max-height: 360px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: #f6f8f7;
  object-fit: contain;
}

.message-video,
.message-audio {
  display: block;
  width: min(360px, 100%);
  margin-bottom: 8px;
}

.message-video {
  max-height: 360px;
  border-radius: 8px;
  background: #0f1715;
}

.message-audio {
  min-width: min(320px, 100%);
}

.message small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.reply-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.reply-compose {
  position: relative;
  display: grid;
}

.reply-compose textarea {
  padding-right: 52px;
}

.reply-attachment-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 34px;
}

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

.reply-tools,
.reply-send-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reply-send-actions {
  justify-content: flex-end;
}

.reply-send-actions .primary-action {
  margin-left: 32px;
}

#closeConversationButton {
  position: absolute;
  top: 16px;
  right: 22px;
  z-index: 4;
  min-width: 94px;
}

.reply-send-actions .primary-action,
.reply-send-actions .warning-action,
.reply-send-actions .blue-action {
  min-height: 38px;
  padding: 0 13px;
}

.reply-tools .icon-action,
.quick-reply-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.reply-tools .icon-action {
  display: grid;
  width: 38px;
  place-items: center;
  padding: 0;
}

.reply-tools .icon-action svg,
.quick-reply-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.quick-reply-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 0 10px;
  font-weight: 700;
}

.reply-tools .icon-action:hover,
.reply-tools .icon-action[aria-expanded="true"],
.quick-reply-button:hover,
.quick-reply-button[aria-expanded="true"] {
  border-color: var(--brand);
  background: #edf8f3;
}

.reply-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  display: grid;
  width: min(340px, calc(100vw - 48px));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.reply-popover[hidden] {
  display: none;
}

.forward-popover,
.retake-popover {
  left: auto;
  right: 0;
}

.quick-reply-menu-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.quick-reply-menu-list button {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.quick-reply-menu-list button:hover {
  border-color: var(--brand);
  background: #edf8f3;
}

.quick-reply-menu-list span {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.reply-attachment-row input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.attachment-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.attachment-button:hover {
  border-color: var(--brand);
  background: #edf8f3;
}

.attachment-button.active {
  border-color: var(--brand);
  background: #d9f3e8;
  color: #075f46;
}

.attachment-name {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-action {
  min-height: 34px;
  padding: 0 10px;
}

.reply-template-row {
  flex: 0 1 220px;
  min-width: 180px;
}

.reply-template-row[hidden] {
  display: none;
}

.reply-template-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

.reply-template-row select {
  width: 100%;
  max-width: 220px;
}

.emoji-toggle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.emoji-toggle:hover,
.emoji-toggle[aria-expanded="true"] {
  border-color: var(--brand);
  background: #edf8f3;
}

.emoji-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: grid;
  width: min(328px, 100%);
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.emoji-panel[hidden] {
  display: none;
}

.emoji-option {
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 1.15rem;
  cursor: pointer;
}

.emoji-option:hover {
  border-color: var(--brand);
  background: #edf8f3;
}

.reply-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.reply-actions select {
  max-width: 220px;
}

.primary-action,
.ghost-action,
.danger-action,
.warning-action,
.blue-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 700;
}

.primary-action {
  background: var(--brand);
  color: #fff;
}

.primary-action:hover {
  background: var(--brand-dark);
}

.ghost-action {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.danger-ghost-action {
  border-color: #ffd6d2;
  background: #fff7f6;
  color: var(--danger);
}

.danger-ghost-action:hover {
  background: #fff1ef;
}

.sidebar .ghost-action {
  background: rgba(255, 255, 255, 0.08);
  color: #f4fffb;
}

.danger-action {
  background: #fff1ef;
  color: var(--danger);
}

.warning-action {
  background: #fff0d7;
  color: var(--warning);
}

.warning-action:hover {
  background: #ffe1a8;
}

.blue-action {
  background: var(--accent);
  color: #fff;
}

.blue-action:hover {
  background: #1b4688;
}

.link-action {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 700;
  text-align: center;
}

.full-width {
  width: 100%;
}

.management-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#settingsView {
  position: relative;
}

#settingsView > .settings-pane {
  position: relative;
  z-index: 1;
}

.settings-tabs[hidden],
#settingsView > .settings-tabs {
  display: none;
}

.settings-navigation {
  position: sticky;
  top: 91px;
  z-index: 15;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin: -2px 0 14px;
  padding: 10px 0;
  background: var(--bg);
}

.settings-navigation .settings-tab {
  flex: 0 0 auto;
}

.settings-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.settings-tab.active {
  border-color: var(--brand);
  background: #edf8f3;
  color: var(--brand-dark);
}

.quick-reply-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quick-reply-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.quick-reply-card div:first-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.quick-reply-card span,
.quick-reply-card p {
  color: var(--muted);
  font-size: 0.84rem;
}

.quick-reply-card p {
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.settings-pane[hidden] {
  display: none;
}

.permission-grid {
  display: grid;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.permission-row {
  display: grid;
  grid-template-columns: minmax(112px, 140px) repeat(12, minmax(78px, 1fr));
  min-width: 1160px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: .78rem;
}

.permission-row:last-child {
  border-bottom: 0;
}

.permission-row > strong,
.permission-row > span,
.permission-check {
  min-height: 34px;
  display: grid;
  align-items: center;
  padding: 4px 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.permission-header {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .86rem;
}

.permission-check {
  justify-items: center;
}

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

.form-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
}

#templatesView .management-layout {
  grid-template-columns: minmax(420px, 520px) minmax(0, 1fr);
}

.template-create-form {
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}

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

.template-form-grid label,
.template-variable-samples label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.template-variable-samples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.template-variable-samples[hidden] {
  display: none;
}

.template-variable-samples > strong {
  grid-column: 1 / -1;
}

.template-button-editor {
  display: grid;
  gap: 9px;
  padding-top: 4px;
}

.template-button-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#templateButtons {
  display: grid;
  gap: 8px;
}

.template-button-row {
  display: grid;
  grid-template-columns: minmax(125px, .8fr) minmax(130px, 1fr) minmax(150px, 1.3fr) minmax(120px, 1fr) 38px;
  gap: 7px;
  align-items: center;
}

.template-button-row [hidden] {
  display: none;
}

.template-button-row .icon-action {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.15rem;
}

.template-component-text {
  margin: 0;
}

.template-button-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.template-button-summary span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: .82rem;
}

#clientsView .form-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
}

.form-panel label,
.dialog-card label,
.login-form label,
.inline-send label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.template-preview-field {
  position: relative;
}

.template-preview-cloud {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 10px);
  z-index: 40;
  display: grid;
  width: min(440px, calc(100vw - 48px));
  gap: 7px;
  overflow: visible;
  border: 1px solid #87b9a8;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7fffb;
  color: var(--text);
  box-shadow: 0 14px 30px rgba(18, 35, 31, 0.18);
  pointer-events: none;
}

.template-preview-cloud::after {
  position: absolute;
  left: 22px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid #87b9a8;
  border-bottom: 1px solid #87b9a8;
  background: #f7fffb;
  content: "";
  transform: rotate(45deg);
}

.template-preview-cloud[hidden] {
  display: none;
}

.template-preview-cloud strong {
  color: var(--brand-dark);
  font-size: 0.84rem;
}

.template-preview-cloud span {
  max-height: 220px;
  overflow-y: auto;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: pre-wrap;
}

.retake-template-field {
  display: block;
  min-width: 250px;
}

.retake-template-options {
  display: grid;
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.retake-template-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.retake-template-option:last-child {
  border-bottom: 0;
}

.retake-template-option:hover,
.retake-template-option:focus-visible,
.retake-template-option.selected {
  background: #e9f8f2;
  color: var(--brand-dark);
}

.retake-template-option span {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retake-template-option small {
  color: var(--muted);
  font-size: 0.72rem;
}

.retake-template-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.retake-template-cloud {
  right: 0;
  left: auto;
  width: min(420px, calc(100vw - 48px));
}

.retake-template-cloud::after {
  right: 22px;
  left: auto;
}

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

.check-row {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: auto;
}

.account-check-list {
  display: grid;
  max-height: 190px;
  gap: 8px;
  overflow-y: auto;
}

.account-check-row {
  display: grid !important;
  grid-template-columns: auto minmax(110px, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 8px !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text) !important;
}

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

.account-check-row span:last-child {
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-hint,
.empty-inline {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.agent-grid,
.user-grid {
  display: grid;
  gap: 0;
  padding: 0;
}

.user-grid {
  overflow-x: auto;
}

.user-grid .empty-state {
  padding: 24px;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(260px, 1.3fr) minmax(150px, auto) minmax(170px, auto);
  gap: 12px;
  align-items: center;
  min-width: 820px;
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  background: var(--surface);
}

.user-card > * {
  min-width: 0;
}

.user-row-name,
.user-row-accounts {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row-status {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.user-card:last-child {
  border-bottom: 0;
}

.user-card .user-title {
  justify-content: start;
}

.user-card .user-avatar {
  flex: 0 0 auto;
}

.user-card .role-chip {
  justify-self: start;
}

.user-card .user-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.user-card .user-actions button {
  flex: 0 0 auto;
}

.phone-prefix-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.phone-prefix-field span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.phone-prefix-field input {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.phone-prefix-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 138, 99, 0.14);
}

.template-grid {
  display: grid;
  gap: 0;
  padding: 0;
}

.template-row {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.template-row:last-child {
  border-bottom: 0;
}

.template-row-main {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(360px, 1.4fr) 40px;
  gap: 14px;
  align-items: center;
  min-height: 62px;
  padding: 9px 14px;
}

.template-row-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.template-row-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-row-title .badge {
  flex: 0 0 auto;
}

.template-qualitrack-flag {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 5px;
  align-items: center;
  min-height: 28px;
  margin: 0;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.template-qualitrack-flag:has(input:checked) {
  border-color: var(--brand);
  background: #e7f7f0;
  color: var(--brand-dark);
}

.template-qualitrack-flag input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}

.template-row-media {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.template-row-media input {
  min-width: 0;
}

.template-row-media button {
  white-space: nowrap;
}

.template-expand-button {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.template-expand-button::before {
  position: absolute;
  top: 12px;
  left: 13px;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
  transition: transform 160ms ease, top 160ms ease;
}

.template-expand-button:hover,
.template-expand-button:focus-visible {
  border-color: var(--brand);
  background: #edf8f3;
  color: var(--brand-dark);
}

.template-row.expanded .template-expand-button::before {
  top: 16px;
  transform: rotate(225deg);
}

.template-row-details {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 14px 68px 16px 14px;
  background: var(--surface-2);
}

.template-row-details[hidden] {
  display: none;
}

.template-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.template-row-meta span {
  color: var(--muted);
  font-size: 0.84rem;
}

.template-row .template-body {
  margin: 0;
  white-space: pre-wrap;
}

.template-row-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  #templatesView .management-layout,
  .template-form-grid,
  .template-variable-samples {
    grid-template-columns: 1fr;
  }

  .template-variable-samples > strong {
    grid-column: auto;
  }

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

  .template-button-row > :not(.icon-action) {
    grid-column: 1;
  }

  .template-button-row .icon-action {
    grid-column: 2;
    grid-row: 1;
  }

  .template-row-main {
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .template-row-media {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .template-expand-button {
    grid-column: 2;
    grid-row: 1;
  }

  .template-row-details {
    padding-right: 14px;
  }
}

.client-grid {
  display: grid;
  gap: 0;
  padding: 0;
}

#clientsView .table-panel > .panel-header {
  position: sticky;
  top: 92px;
  z-index: 9;
  background: var(--surface);
}

#clientsView .table-panel > .client-pagination-bar:not(.bottom) {
  position: sticky;
  top: 169px;
  z-index: 8;
}

.client-pagination-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  background: var(--surface-2);
}

.client-pagination-bar.bottom {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.client-pagination-bar label {
  display: grid;
  grid-template-columns: auto 86px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.client-pagination-bar select {
  min-height: 34px;
  padding: 7px 9px;
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.agent-card,
.template-card,
.client-card {
  display: grid;
  gap: 10px;
  min-height: 142px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.client-card {
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, 0.8fr) minmax(390px, auto);
  gap: 12px;
  align-items: center;
  min-height: 56px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 14px;
  background: var(--surface);
}

.client-card > strong,
.client-phone-line {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.client-name-line .blocked-client-tag {
  flex: 0 0 auto;
}

.blocked-client-tag {
  border: 1px solid #dc2626;
  border-radius: 999px;
  padding: 2px 8px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.client-card.blocked {
  background: #fff7f0;
}

.client-card:last-child {
  border-bottom: 0;
}

.client-card .user-title {
  justify-content: start;
}

.client-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.client-card .ghost-action,
.client-card .primary-action,
.client-card .warning-action,
.client-card .danger-action {
  min-width: 76px;
  min-height: 36px;
  padding: 0 10px;
}

.client-card .icon-action {
  display: inline-grid;
  width: 36px;
  min-width: 36px;
  padding: 0;
  place-items: center;
}

.icon-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.agent-avatar,
.user-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #e7effd;
  color: var(--accent);
  font-weight: 800;
}

.user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.user-actions button {
  flex: 1 1 120px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.history-list.expanded {
  max-height: min(520px, 70vh);
}

.history-item {
  border-left: 3px solid var(--gold);
  padding: 8px 10px;
  background: #fffdf7;
  color: var(--muted);
  line-height: 1.35;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.role-chip {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  background: #e7effd;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
}

.template-body {
  color: var(--muted);
  line-height: 1.45;
}

.template-media-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.template-media-field input {
  min-width: 0;
}

.bulk-preview {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.post-sale-grid {
  display: grid;
  gap: 0;
  padding: 0;
}

.post-sale-card {
  display: grid;
  grid-template-columns: 38px minmax(220px, 1.45fr) minmax(120px, 0.7fr) minmax(105px, 0.55fr) minmax(160px, 1fr) minmax(90px, 0.55fr) minmax(90px, 0.55fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  background: var(--surface);
}

.sales-survey-card,
.sales-survey-header {
  grid-template-columns: 38px minmax(220px, 1.35fr) minmax(110px, 0.6fr) minmax(120px, 0.68fr) minmax(105px, 0.52fr) minmax(150px, 0.95fr) minmax(120px, 0.6fr) minmax(90px, 0.5fr) minmax(210px, 1.05fr);
}

.later-purchase-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--muted);
}

.later-purchase-cell.has-purchase {
  color: var(--text);
}

.later-purchase-cell.has-purchase strong {
  color: var(--brand);
}

.later-purchase-cell small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-survey-panel-actions,
.view-tabs,
.schedule-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-tabs {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px;
  background: var(--surface-2);
}

.view-tab {
  border: 0;
  border-radius: 5px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.view-tab.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(18, 35, 31, 0.12);
}

.schedule-action {
  border-color: #1482a6;
  color: #0c6a89;
}

.sales-schedule-pane,
.sales-schedule-grid {
  min-width: 0;
}

.sales-schedule-grid {
  display: grid;
  overflow-x: auto;
}

.sales-schedule-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(100px, 0.75fr) minmax(130px, 1fr) minmax(110px, 0.8fr) minmax(120px, 0.85fr) 58px 68px 56px 68px minmax(150px, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  background: var(--surface);
  min-width: 1180px;
}

.sales-schedule-row > span,
.sales-schedule-row > strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sales-schedule-header {
  min-height: 42px;
  background: #f6f8f7;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.schedule-status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8eeec;
  color: #53655f;
  font-size: 0.72rem;
  font-weight: 900;
}

.schedule-status.pending { background: #fff0cf; color: #9a5b00; }
.schedule-status.running { background: #dcecff; color: #175fa9; }
.schedule-status.completed { background: #d9f8e8; color: #08734f; }
.schedule-status.partial { background: #fff0cf; color: #9a5b00; }
.schedule-status.failed { background: #ffe2e2; color: #b42318; }
.schedule-status.cancelled { background: #ecefee; color: #65736f; }
.schedule-success { color: #08734f; }
.schedule-failure { color: #b42318; }

.schedule-general-error {
  grid-column: 1 / -1;
  margin: 0;
  border-top: 1px solid #f3c1bd;
  padding-top: 8px;
  color: #9e2b22;
  font-size: 0.8rem;
}

.schedule-confirmation-summary {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: var(--surface-2);
}

.sales-schedule-details {
  display: grid;
  max-height: 62vh;
  overflow: auto;
}

.sales-schedule-detail-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) minmax(130px, 0.8fr) minmax(90px, 0.55fr) minmax(90px, 0.55fr) minmax(220px, 1.5fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
}

.sales-schedule-detail-row > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-sale-card.blocked {
  background: #fff7f0;
}

.post-sale-header {
  min-height: 42px;
  background: #f6f8f7;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.post-sale-header span,
.post-sale-header strong {
  color: var(--ink);
  font-weight: 800;
}

.sales-sort-button {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.sales-sort-button:hover,
.sales-sort-button:focus-visible {
  color: var(--brand);
}

.post-sale-card:last-child {
  border-bottom: 0;
}

.post-sale-card span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.survey-name-cell {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.post-sale-card .survey-name-text {
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.3;
  text-overflow: clip;
  white-space: normal;
}

.survey-status-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  background: #d9f8e8;
  color: #08734f;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.survey-status-tag.failure {
  background: #fee2e2;
  color: #b91c1c;
}

.survey-status-tag.failure.media {
  background: #ffedd5;
  color: #9a3412;
}

.row-check {
  display: inline-flex;
  align-items: center;
}

.row-check input {
  width: 18px;
  height: 18px;
}

.bulk-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 160px) minmax(130px, 1fr) minmax(160px, 1fr) minmax(148px, auto);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.bulk-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8f7;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.bulk-header span,
.bulk-header strong {
  color: var(--ink);
  font-weight: 800;
}

.bulk-row span,
.bulk-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.bulk-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.logs-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.logs-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.security-log-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.security-log-metric {
  display: grid;
  gap: 6px;
  min-height: 72px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.security-log-metric span {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.security-log-metric strong {
  color: var(--ink);
  font-size: 1.22rem;
}

@media (max-width: 1180px) {
  .security-log-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .security-log-metrics {
    grid-template-columns: 1fr;
  }
}

.security-logs-grid {
  display: grid;
  gap: 8px;
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

.security-log-row {
  display: grid;
  grid-template-columns: minmax(125px, 150px) minmax(130px, 155px) minmax(130px, 1fr) minmax(170px, 1.2fr) minmax(105px, 135px) minmax(90px, 105px) minmax(180px, 1.4fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.security-log-row.failure {
  border-color: #efb1b1;
  background: #fff4f4;
}

.security-log-row span,
.security-log-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.security-log-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8f7;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.faq-search {
  margin: 0 0 14px;
}

.meta-faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
  align-items: start;
}

.meta-faq-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
  min-width: 0;
  height: auto;
}

.meta-faq-code {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.meta-faq-code strong {
  display: inline-grid;
  min-width: 82px;
  min-height: 36px;
  place-items: center;
  border-radius: 8px;
  background: #102f2a;
  color: #ffffff;
  font-size: 0.98rem;
  line-height: 1;
}

.meta-faq-code span {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  min-width: 0;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8f5ef;
  color: #0b6f56;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}

.meta-faq-content {
  min-width: 0;
}

.meta-faq-content h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta-faq-content p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.meta-faq-content dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.meta-faq-content dt {
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.meta-faq-content dd {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (min-width: 1420px) {
  .meta-faq-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .meta-faq-grid {
    grid-template-columns: 1fr;
  }
}

.log-metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.log-metric strong {
  color: var(--ink);
  font-size: 1.35rem;
}

.log-metric small {
  color: var(--muted);
  font-weight: 800;
}

.log-metric span {
  color: var(--muted);
  font-weight: 700;
}

.log-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #dde7e3;
  overflow: hidden;
}

.log-bar i {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--brand));
}

.score-dashboard {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.score-dashboard > div:first-child {
  display: grid;
  align-content: center;
  gap: 8px;
}

.score-dashboard span,
.score-dashboard small {
  color: var(--muted);
  font-weight: 800;
}

.score-dashboard strong {
  color: var(--ink);
  font-size: 1.45rem;
}

.nps-panel {
  display: grid;
  gap: 3px;
  border: 1px solid #a7d5c0;
  border-radius: 8px;
  padding: 10px;
  background: #ecf8f2;
}

.nps-panel strong {
  color: #0b6f56;
  font-size: 1.75rem;
}

.nps-groups {
  display: grid;
  gap: 6px;
}

.nps-groups span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
}

.nps-groups strong {
  margin-left: auto;
  font-size: 0.82rem;
}

.nps-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand);
}

.nps-dot.promoter {
  background: #2f9b6b;
}

.nps-dot.neutral {
  background: #0b83bd;
}

.nps-dot.detractor {
  background: #d15f4c;
}

.score-bars {
  display: grid;
  gap: 7px;
}

.score-row {
  display: grid;
  grid-template-columns: 24px minmax(90px, 1fr) 36px 44px;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.score-row:hover:not(:disabled),
.score-row.selected {
  border-color: #7fb9a6;
  background: #e7f5ef;
}

.score-row.selected {
  box-shadow: 0 0 0 2px rgba(22, 138, 99, 0.18);
}

.score-row:disabled {
  cursor: default;
  opacity: 0.58;
}

.score-row strong,
.score-row span,
.score-row small {
  font-size: 0.82rem;
}

.logs-grid {
  display: grid;
  gap: 8px;
  max-height: 56vh;
  overflow: auto;
  padding-right: 4px;
}

.log-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.74fr) minmax(108px, 132px) minmax(108px, 140px) minmax(78px, 102px) minmax(88px, 112px) minmax(112px, 136px) minmax(72px, 90px) minmax(82px, 100px) minmax(74px, 92px);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.log-row.has-actions {
  grid-template-columns: minmax(110px, 0.74fr) minmax(108px, 132px) minmax(108px, 140px) minmax(78px, 102px) minmax(88px, 112px) minmax(112px, 136px) minmax(72px, 90px) minmax(82px, 100px) minmax(74px, 92px) 44px;
}

.log-actions {
  display: flex;
  justify-content: center;
  overflow: visible;
}

.log-actions .icon-action {
  width: 34px;
  height: 34px;
  padding: 8px;
}

.log-row.score-critical {
  border-color: #ef9a9a;
  background: #ffebee;
}

.log-row.score-warning {
  border-color: #e8c65a;
  background: #fff8d8;
}

.score-filter-summary {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid #7fb9a6;
  border-radius: 8px;
  padding: 8px 10px;
  background: #e7f5ef;
  color: #0b6047;
  font-weight: 800;
}

.score-filter-summary + .log-header {
  top: 53px;
}

.log-row span,
.log-row strong,
.log-sort-button {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.link-button:hover {
  color: var(--brand);
  text-decoration: underline;
}

.log-client-button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f8f7;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.log-sort-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-transform: uppercase;
}

.log-responded {
  color: var(--brand);
  font-weight: 900;
}

.log-score {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  color: var(--ink) !important;
  font-weight: 900;
  text-align: center;
}

.log-score-value {
  min-width: 18px;
}

.manual-score-editor {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.score-source-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid #7fb9a6;
  border-radius: 999px;
  background: #e7f5ef;
  color: #087a73;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-source-tag.whatsapp {
  border-color: #bdd9d0;
  background: #f2f8f5;
  color: #51615d;
}

.manual-score-select {
  width: 84px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.read-check {
  color: var(--brand) !important;
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
}

.small-action {
  min-height: 34px;
  padding: 8px 10px;
  white-space: nowrap;
}

.nav-item.is-hidden {
  display: none;
}

.integration-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

.integration-panel ol {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 22px;
}

.whatsapp-form-actions,
.whatsapp-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.whatsapp-form-actions > button {
  flex: 1 1 140px;
}

.whatsapp-panel-actions {
  justify-content: flex-end;
}

.whatsapp-account-list {
  display: grid;
  gap: 10px;
}

.integration-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.integration-panel-header h2 {
  margin: 0 0 3px;
}

.integration-panel-header span {
  color: var(--muted);
  font-size: 0.86rem;
}

.whatsapp-account-card {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(160px, 1fr) minmax(155px, auto) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.whatsapp-account-card:last-child {
  border-bottom: 0;
}

.whatsapp-health-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e5ebe8;
  color: #52615d;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.whatsapp-health-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.whatsapp-health-status.quality-green {
  color: #047857;
  background: #d1fae5;
}

.whatsapp-health-status.quality-yellow {
  color: #92400e;
  background: #fef3c7;
}

.whatsapp-health-status.quality-red {
  color: #b91c1c;
  background: #fee2e2;
}

.inline-send {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.api-note {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog.wide-dialog {
  width: min(920px, calc(100vw - 28px));
}

dialog.competitor-insight-dialog {
  width: min(760px, calc(100vw - 28px));
}

dialog.vehicle-insight-dialog {
  width: min(820px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(18, 35, 31, 0.42);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.competitor-insight-summary {
  margin: 0 0 14px;
  color: var(--text);
  line-height: 1.5;
}

.competitor-insight-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.competitor-insight-columns section,
.competitor-insight-approach {
  min-width: 0;
}

.competitor-insight-dialog h3,
.vehicle-insight-dialog h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.competitor-insight-dialog ul,
.vehicle-insight-dialog ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 20px;
}

.competitor-insight-dialog li,
.vehicle-insight-dialog li {
  line-height: 1.4;
}

.competitor-insight-approach {
  padding-top: 14px;
}

.competitor-insight-caution,
.competitor-insight-private {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid #d99b27;
  color: #5d450f;
  background: #fff8e8;
  line-height: 1.4;
}

.vehicle-insight-guidance {
  border-top: 0;
}

.vehicle-insight-sources {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.competitor-insight-private {
  color: var(--muted);
  border-left-color: var(--brand);
  background: var(--surface-2);
  font-size: 0.82rem;
}

.history-score {
  border: 1px solid #7fb9a6;
  border-radius: 8px;
  padding: 10px;
  background: #e7f5ef;
  color: #0b6047;
  font-weight: 900;
}

.history-chat {
  display: grid;
  gap: 10px;
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

.history-message {
  display: grid;
  gap: 6px;
  max-width: 78%;
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(18, 35, 31, 0.08);
}

.history-message.agent {
  justify-self: end;
  background: #dcf7ea;
}

.history-message.customer {
  justify-self: start;
}

.history-message small {
  color: var(--muted);
  font-weight: 700;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(24px);
  opacity: 0;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #12231f;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.ai-settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(520px, 1.4fr);
  gap: 14px;
  align-items: start;
}

.ai-settings-grid > * {
  min-width: 0;
}

.ai-agent-form textarea {
  resize: vertical;
}

.ai-agent-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ai-document-library {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ai-document-library h3 {
  margin: 0 0 3px;
  font-size: 0.95rem;
}

.ai-document-upload-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(220px, 1.3fr) auto;
  gap: 8px;
  align-items: end;
}

.ai-document-list {
  display: grid;
  max-height: 270px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.ai-document-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto auto;
  gap: 9px;
  align-items: center;
  min-height: 48px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
}

.ai-document-row.inactive {
  opacity: 0.65;
}

.ai-document-row > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ai-document-row strong,
.ai-document-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-document-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.ai-document-active {
  display: inline-grid;
  place-items: center;
  margin: 0;
}

.ai-agent-row .row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.ai-agent-detail {
  display: grid;
  gap: 3px;
}

.ai-agent-detail small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-active-check {
  align-self: end;
  min-height: 43px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.ai-agent-list-panel,
.ai-test-panel {
  min-height: 0;
}

.ai-agent-list-panel {
  grid-column: 1;
}

.ai-test-panel {
  grid-column: 2;
}

.ai-jobs-panel {
  grid-column: 1 / -1;
}

.ai-agent-list,
.ai-job-list {
  display: grid;
  gap: 0;
  margin-top: 10px;
}

.ai-agent-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) auto minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.ai-agent-row:last-child,
.ai-job-row:last-child {
  border-bottom: 0;
}

.ai-agent-main,
.ai-agent-main span,
.ai-agent-detail {
  min-width: 0;
}

.ai-agent-main {
  display: grid;
  gap: 2px;
}

.ai-agent-main span,
.ai-agent-detail,
.ai-job-row span,
.ai-job-row small {
  color: var(--muted);
  font-size: 0.82rem;
}

.ai-job-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr) minmax(300px, 1.6fr);
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.ai-job-row.failed {
  background: #fff1f1;
}

.ai-job-row > div {
  display: grid;
  gap: 3px;
}

.ai-job-row p,
.ai-test-result p {
  margin: 0;
  white-space: pre-wrap;
}

.ai-job-row .ai-job-error {
  display: block;
  margin-top: 4px;
  color: var(--danger);
  font-weight: 700;
}

.ai-test-result {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #9fd8c5;
  border-radius: 6px;
  background: #eefaf5;
}

.ai-test-result[hidden] {
  display: none;
}

.api-note.compact {
  margin-top: 8px;
}

@media (max-width: 980px) {
  .login-screen {
    grid-template-columns: 1fr;
    justify-content: center;
  }

  .login-hero-title {
    flex-wrap: wrap;
    white-space: normal;
  }

  .login-brand-panel,
  .login-card {
    width: min(440px, 100%);
    justify-self: center;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace-footer {
    left: 16px;
    right: 16px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
    padding: 16px;
    overflow: visible;
  }

  .nav-list {
    overflow: visible;
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .logs-chart {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .security-log-metrics {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .dashboard-metrics,
  .dashboard-chart-grid {
    grid-template-columns: 1fr;
  }

  .security-log-row {
    grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr);
  }

  .log-row {
    grid-template-columns: minmax(140px, 1fr) minmax(110px, 1fr);
  }

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

  .sidebar-footer {
    margin-top: 0;
  }

  #inboxView.active,
  .management-layout,
  .settings-grid,
  .ai-settings-grid {
    grid-template-columns: 1fr;
  }

  .ai-agent-list-panel,
  .ai-test-panel,
  .ai-jobs-panel {
    grid-column: 1;
  }

  .ai-agent-row,
  .ai-job-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .ai-document-upload-row,
  .ai-document-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .ai-document-active {
    justify-content: start;
  }

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

  .integration-panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .whatsapp-account-card {
    grid-template-columns: minmax(140px, 1fr) auto;
  }

  .whatsapp-account-card .user-actions {
    grid-column: 1 / -1;
  }

  #inboxView.active {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .conversation-list-panel,
  .chat-panel {
    max-height: 72vh;
  }

  .chat-header {
    padding-right: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .chat-insight-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .competitor-insight-columns {
    grid-template-columns: 1fr;
  }

  .reply-toolbar,
  .reply-tools,
  .reply-send-actions {
    flex-wrap: wrap;
  }

  .reply-send-actions {
    justify-content: flex-start;
  }

  #closeConversationButton {
    position: static;
    min-width: 0;
  }

  .reply-popover {
    left: 0;
    right: auto;
    width: min(320px, calc(100vw - 40px));
  }

  .client-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  #clientsView .form-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .client-pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  #clientsView .table-panel > .panel-header,
  #clientsView .table-panel > .client-pagination-bar:not(.bottom) {
    position: static;
  }

  .pagination-controls {
    justify-content: space-between;
  }

  .permission-row {
    min-width: 1160px;
    grid-template-columns: minmax(112px, 140px) repeat(12, minmax(78px, 1fr));
  }

  .post-sale-card {
    grid-template-columns: 38px 1fr;
    align-items: start;
  }

  .bulk-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .post-sale-header {
    display: none;
  }
}

@media (max-width: 640px) {
  .workspace,
  .login-screen {
    padding: 14px;
  }

  .login-card {
    padding: 20px;
  }

  .topbar,
  .reply-actions,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .reply-actions select,
  .reply-template-row,
  .reply-template-row select {
    max-width: none;
    width: 100%;
  }

  .reply-template-row {
    min-width: 0;
  }

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

  .message {
    max-width: 94%;
  }
}
.salespeople-settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.salespeople-history-panel {
  grid-column: 1 / -1;
}

.salespeople-list,
.salespeople-notification-list {
  display: grid;
}

.salesperson-row,
.salesperson-notification-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(220px, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.salesperson-row:first-child,
.salesperson-notification-row:first-child {
  border-top: 0;
}

.salesperson-row.inactive {
  opacity: 0.68;
}

.salesperson-row > div,
.salesperson-notification-row > div {
  min-width: 0;
}

.salesperson-row strong,
.salesperson-row span,
.salesperson-row small,
.salesperson-notification-row strong,
.salesperson-notification-row span {
  display: block;
  overflow-wrap: anywhere;
}

.salesperson-row small,
.salesperson-notification-row small {
  color: var(--muted);
}

.salesperson-lead-count {
  color: var(--muted);
  white-space: nowrap;
}

.salesperson-notification-row {
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
}

@media (max-width: 980px) {
  .salespeople-settings-grid {
    grid-template-columns: 1fr;
  }

  .salesperson-row,
  .salesperson-notification-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.ai-vehicle-library-layout { display: grid; grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); gap: 16px; min-width: 0; }
.ai-vehicle-folder-sidebar { border-right: 1px solid var(--border); padding-right: 14px; min-width: 0; }
.ai-vehicle-folder-toolbar, .ai-vehicle-folder-create, .ai-vehicle-folder-list { display: grid; gap: 8px; }
.ai-vehicle-folder-toolbar input, .ai-vehicle-gallery-toolbar input { width: 100%; min-width: 0; }
.ai-vehicle-folder-toolbar button { justify-self: start; }
.ai-vehicle-folder-create { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ai-vehicle-folder-create[hidden], .ai-vehicle-folder-content[hidden] { display: none; }
.ai-vehicle-folder-list { max-height: 440px; overflow-y: auto; padding-top: 4px; }
.ai-vehicle-model-group { display: grid; gap: 3px; min-width: 0; }
.ai-vehicle-model-group > strong { padding: 8px 6px 3px; font-size: 13px; overflow-wrap: anywhere; }
.ai-vehicle-folder-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: left; cursor: pointer; }
.ai-vehicle-folder-option:hover { background: #eef7f4; }
.ai-vehicle-folder-option.active { border-color: #168a63; background: #eaf8f2; color: #075a40; }
.ai-vehicle-folder-option span { overflow-wrap: anywhere; }
.ai-vehicle-folder-option small { flex: none; color: #5d6b68; }
.ai-vehicle-folder-content { display: grid; align-content: start; gap: 12px; min-width: 0; }
.ai-vehicle-folder-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ai-vehicle-folder-heading strong { overflow-wrap: anywhere; margin-right: auto; }
.ai-vehicle-folder-heading button[hidden] { display: none; }
.ai-vehicle-folder-heading span { white-space: nowrap; color: #586765; font-size: 12px; }
.ai-vehicle-upload-fields { display: grid; grid-template-columns: minmax(100px, 160px) minmax(0, 1fr); gap: 10px; }
.ai-vehicle-upload-preview { display: grid; gap: 6px; }
.ai-vehicle-upload-row { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 8px; align-items: center; }
.ai-vehicle-upload-row img { width: 60px; height: 44px; object-fit: cover; border-radius: 4px; }
.ai-vehicle-upload-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-vehicle-upload-row input { width: 100%; min-width: 0; }
.ai-vehicle-gallery-toolbar { display: flex; justify-content: flex-end; }
.ai-vehicle-gallery-toolbar input { max-width: 240px; }
.ai-vehicle-image-list { display: grid; gap: 8px; max-height: 390px; overflow-y: auto; }
.ai-vehicle-image-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }
.ai-vehicle-image-row.inactive { opacity: 0.6; }
.ai-vehicle-image-row img { width: 76px; height: 58px; object-fit: cover; border-radius: 4px; }
.ai-vehicle-image-row > div { display: grid; min-width: 0; }
.ai-vehicle-image-row strong, .ai-vehicle-image-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  .ai-vehicle-library-layout { grid-template-columns: 1fr; }
  .ai-vehicle-folder-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 10px; }
  .ai-vehicle-folder-list { max-height: 180px; }
}
@media (max-width: 760px) {
  .ai-vehicle-upload-fields { grid-template-columns: 1fr; }
  .ai-vehicle-upload-row { grid-template-columns: 48px minmax(0, 1fr); }
  .ai-vehicle-upload-row img { width: 48px; height: 42px; }
  .ai-vehicle-image-row { grid-template-columns: 64px minmax(0, 1fr); }
  .ai-vehicle-image-row img { width: 64px; height: 52px; }
}
/* Narrow-screen navigation keeps the inbox list and chat as separate screens. */
.mobile-menu-toggle,
.mobile-chat-back { display: none; }
@media (max-width: 980px) {
  .sidebar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .sidebar .brand { min-width: 0; }
  .sidebar .brand-logo { width: min(148px, 100%); }
  .mobile-menu-toggle { display: block; min-height: 40px; border: 1px solid rgba(255,255,255,.38); border-radius: 6px; padding: 6px 12px; background: transparent; color: inherit; }
  .sidebar .nav-list,
  .sidebar .sidebar-footer,
  .sidebar .sidebar-zapflow-logo { display: none; }
  .sidebar[data-menu-open="true"] .nav-list,
  .sidebar[data-menu-open="true"] .sidebar-footer { display: grid; grid-column: 1 / -1; }
  .sidebar[data-menu-open="true"] .sidebar-zapflow-logo { display: block; grid-column: 1 / -1; }
  .sidebar[data-menu-open="true"] .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #inboxView.active { display: block; height: calc(100dvh - 170px); min-height: 320px; overflow: hidden; }
  #inboxView .conversation-list-panel,
  #inboxView .chat-panel { height: 100%; max-height: none; }
  #inboxView[data-mobile-pane="list"] .chat-panel,
  #inboxView[data-mobile-pane="chat"] .conversation-list-panel { display: none; }
  #inboxView .chat-panel { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .mobile-chat-back:not([hidden]) { display: block; justify-self: start; margin: 8px 12px 0; border: 0; background: transparent; color: var(--brand-dark); font-weight: 700; }
  .chat-header .chat-title { min-width: 0; overflow-wrap: anywhere; }
  .workspace-footer { display: none; }
}
@media (max-width: 640px) {
  .sidebar[data-menu-open="true"] .nav-list { grid-template-columns: 1fr; }
  #inboxView.active { height: calc(100dvh - 190px); }
}
