/* Component layout and interactions. Shared presentation: interface.css. */
/* Constructor visual de flujos */
.automation-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #eef0f4;
}

:root[data-theme="dark"] .automation-view {
  background: #111317;
}

.workflow-builder-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  z-index: 4;
}

.workflow-builder-heading,
.workflow-builder-actions,
.workflow-panel-heading,
.workflow-section-title,
.workflow-action-editor header,
.workflow-node header,
.workflow-canvas-toolbar,
.workflow-zoom-controls {
  display: flex;
  align-items: center;
}

.workflow-builder-heading {
  min-width: 0;
  gap: 12px;
}

.workflow-builder-heading > div {
  min-width: 0;
}

.workflow-builder-heading .eyebrow {
  margin: 0 0 2px;
  font-size: 10px;
}

.workflow-builder-heading h2 {
  max-width: 440px;
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-back-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 27px;
  line-height: 1;
}

.workflow-builder-actions {
  flex: 0 0 auto;
  gap: 8px;
}

.workflow-builder-actions .secondary-button,
.workflow-builder-actions .send-button {
  min-height: 38px;
  padding: 0 14px;
}

.workflow-publish-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.workflow-publish-status.is-published {
  border-color: color-mix(in srgb, #3fd48a 40%, var(--line));
  background: color-mix(in srgb, #3fd48a 13%, transparent);
  color: #38c783;
}

.workflow-publish-status.is-paused {
  border-color: color-mix(in srgb, var(--amber) 48%, var(--line));
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber);
}

.workflow-builder {
  display: grid;
  grid-template-columns: 248px minmax(460px, 1fr) 326px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.workflow-library,
.workflow-inspector {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--panel);
}

.workflow-library {
  border-right: 1px solid var(--line);
}

.workflow-inspector {
  padding-bottom: 24px;
  border-left: 1px solid var(--line);
}

.workflow-panel-heading {
  justify-content: space-between;
  gap: 10px;
  min-height: 68px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.workflow-panel-heading > div {
  display: grid;
  gap: 2px;
}

.workflow-panel-heading span,
.workflow-section-title span {
  font-size: 13px;
  font-weight: 800;
}

.workflow-panel-heading small,
.workflow-section-title small {
  color: var(--muted);
  font-size: 10px;
}

.workflow-icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line));
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 21px;
}

.workflow-list {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.workflow-list-item {
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
}

.workflow-list-item:hover,
.workflow-list-item:focus-within,
.workflow-list-item.is-selected {
  border-color: color-mix(in srgb, #7d5cf0 52%, var(--line));
  background: color-mix(in srgb, #7d5cf0 10%, var(--panel));
}

.workflow-list-select {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 8px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.workflow-list-select > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.workflow-list-select strong,
.workflow-list-select small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-list-select strong { font-size: 11px; }
.workflow-list-select small { color: var(--muted); font-size: 9px; }

.workflow-list-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #8b66f4, #5b3ec5);
  color: white;
  font-size: 18px;
}

.workflow-state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.workflow-state-dot.is-active {
  background: #3fd48a;
  box-shadow: 0 0 0 3px rgba(63, 212, 138, 0.13);
}

.workflow-list-actions {
  /* Keep the action row in layout so hovering never moves adjacent cards. */
  display: flex;
  gap: 5px;
  padding: 0 10px 9px 48px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.workflow-list-item:hover .workflow-list-actions,
.workflow-list-item:focus-within .workflow-list-actions,
.workflow-list-item.is-selected .workflow-list-actions {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .workflow-list-actions {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
}

.workflow-list-actions button {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 9px;
}

.workflow-list-actions button:last-child:hover { color: var(--rose); }

.workflow-library-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 42px 18px;
  color: var(--muted);
  text-align: center;
}

.workflow-library-empty > span { font-size: 32px; }
.workflow-library-empty strong { color: var(--ink); font-size: 12px; }
.workflow-library-empty small { font-size: 10px; line-height: 1.5; }

.workflow-canvas-panel {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: #202329;
}

.workflow-canvas-toolbar {
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #17191e;
  color: #aeb4c0;
  font-size: 10px;
}

.workflow-canvas-toolbar > span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.workflow-canvas-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-fullscreen-button {
  display: grid;
  width: 29px;
  height: 27px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: #2d313a;
  color: #f2f3f6;
  font-size: 10px;
  font-weight: 700;
}

.workflow-fullscreen-button:hover { background: #3a404b; }
.workflow-fullscreen-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.workflow-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3fd48a;
  box-shadow: 0 0 0 3px rgba(63, 212, 138, 0.12);
}

.workflow-zoom-controls {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
}

.workflow-zoom-controls button {
  min-width: 30px;
  height: 27px;
  padding: 0 8px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  background: #24272e;
  color: #dfe3ea;
  font-size: 11px;
}

.workflow-zoom-controls button:last-child { border-right: 0; }

.workflow-canvas {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  background-color: #202329;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.17) 1px, transparent 1.25px);
  background-position: 0 0;
  background-size: 22px 22px;
}

.workflow-canvas.is-panning { cursor: grabbing; user-select: none; }
.workflow-canvas .workflow-action-node,
.workflow-canvas button { cursor: pointer; }
.workflow-canvas .workflow-action-node.is-draggable { cursor: grab; }

body.workflow-canvas-expanded { overflow: hidden; }

.workflow-canvas-panel.is-expanded {
  position: fixed;
  z-index: 1000;
  inset: 0;
  height: 100dvh;
  grid-template-rows: 52px minmax(0, 1fr);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
}

.workflow-canvas-panel.is-expanded .workflow-canvas-toolbar { padding-inline: 20px; }
.workflow-canvas-panel.is-expanded .workflow-stage { padding: 80px 180px 150px; }

.workflow-stage {
  display: grid;
  justify-items: center;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 58px 110px 120px;
  transform-origin: center top;
  transition: transform 180ms ease;
}

.workflow-node {
  width: 310px;
  overflow: hidden;
  border: 1px solid #3a3e47;
  border-radius: 13px;
  background: #101216;
  color: #f2f3f6;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.3);
}

.workflow-node:hover {
  border-color: #6d7482;
  transform: translateY(-1px);
}

.workflow-node header {
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid #2e3239;
}

.workflow-node header strong {
  flex: 1;
  font-size: 13px;
}

.workflow-node-icon,
.workflow-mini-icon {
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 800;
}

.workflow-node-icon {
  width: 29px;
  height: 29px;
  color: #ff2c7c;
  font-size: 17px;
}

.workflow-node-menu { color: #7f8693; letter-spacing: 2px; }

.workflow-node > div {
  display: grid;
  gap: 4px;
  padding: 13px 16px 15px;
}

.workflow-node > div span {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-node > div small { color: #8f96a3; font-size: 10px; }
.workflow-trigger-node { border-color: #ad1953; }
.workflow-trigger-node header { background: linear-gradient(90deg, rgba(234, 29, 106, 0.16), transparent 34%); }
.workflow-action-node { cursor: pointer; }
.workflow-action-node.is-draggable { cursor: grab; }
.workflow-action-node.is-draggable:active { cursor: grabbing; }
.workflow-action-node.is-dragging { opacity: 0.42; }
.workflow-action-node.is-drop-target { border-color: #ff2c7c; box-shadow: 0 0 0 3px rgba(255, 44, 124, 0.24), 0 18px 34px rgba(0, 0, 0, 0.3); }
.workflow-action-node.assign header { background: linear-gradient(90deg, rgba(139, 102, 244, 0.16), transparent 34%); }
.workflow-action-node.tag header { background: linear-gradient(90deg, rgba(241, 189, 66, 0.16), transparent 34%); }
.workflow-action-node.reply header { background: linear-gradient(90deg, rgba(47, 184, 242, 0.16), transparent 34%); }
.workflow-action-node.buttons header { background: linear-gradient(90deg, rgba(49, 198, 161, 0.16), transparent 34%); }
.workflow-action-node.assign .workflow-node-icon { color: #a988ff; }
.workflow-action-node.tag .workflow-node-icon { color: #ffd15a; }
.workflow-action-node.reply .workflow-node-icon { color: #50c9ff; }
.workflow-action-node.buttons .workflow-node-icon { color: #46dbb6; }

.workflow-flow-step {
  display: grid;
  justify-items: center;
}

.workflow-connector {
  position: relative;
  width: 2px;
  height: 62px;
  background: #35a9ee;
}

.workflow-connector::before,
.workflow-connector::after {
  position: absolute;
  left: 50%;
  width: 7px;
  height: 7px;
  border: 2px solid #202329;
  border-radius: 50%;
  background: #35a9ee;
  content: "";
  transform: translateX(-50%);
}

.workflow-connector::before { top: -3px; }
.workflow-connector::after { bottom: -3px; }

.workflow-connector span {
  position: absolute;
  top: 23px;
  left: 12px;
  width: max-content;
  padding: 4px 7px;
  border-radius: 6px;
  background: #303641;
  color: #6dbaff;
  font-size: 9px;
  font-weight: 700;
}

.workflow-add-step button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px dashed #515763;
  border-radius: 9px;
  background: #1b1e24;
  color: #b7bdc7;
  font-size: 10px;
}

.workflow-add-step button span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 6px;
  background: #7052d8;
  color: white;
}

.workflow-field,
.workflow-action-editor label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.workflow-field {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.workflow-field input,
.workflow-action-editor input,
.workflow-action-editor select,
.workflow-action-editor textarea {
  width: 100%;
  border-color: var(--line);
  background: var(--input);
  color: var(--ink);
  font-size: 11px;
}

.workflow-field input { min-height: 39px; }

.workflow-trigger-summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 14px 16px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 86%, var(--accent-soft));
}

.workflow-trigger-summary > div { display: grid; gap: 3px; }
.workflow-trigger-summary strong { font-size: 10px; }
.workflow-trigger-summary small { color: var(--muted); font-size: 9px; line-height: 1.4; }

.workflow-mini-icon {
  width: 28px;
  height: 28px;
  font-size: 13px;
}

.workflow-mini-icon.trigger { background: rgba(234, 29, 106, 0.14); color: #ed327b; }
.workflow-mini-icon.assign { background: rgba(139, 102, 244, 0.15); color: #9878f5; }
.workflow-mini-icon.tag { background: rgba(241, 189, 66, 0.16); color: #dca82d; }
.workflow-mini-icon.reply { background: rgba(47, 184, 242, 0.15); color: #2ea9dd; }
.workflow-mini-icon.buttons { background: rgba(49, 198, 161, 0.15); color: #22a985; }

.workflow-inspector-section {
  display: grid;
  gap: 10px;
  padding: 4px 16px 14px;
}

.workflow-section-title { justify-content: space-between; }

.workflow-action-palette {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.workflow-action-palette button {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  font-size: 9px;
}

.workflow-action-palette button:hover {
  border-color: color-mix(in srgb, #7d5cf0 52%, var(--line));
  background: color-mix(in srgb, #7d5cf0 7%, var(--panel));
  color: var(--ink);
}

.workflow-actions-editor {
  display: grid;
  gap: 9px;
  padding: 0 16px;
}

.workflow-action-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 94%, var(--page));
}

.workflow-action-editor header {
  gap: 7px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
}

.workflow-action-editor header strong { flex: 1; font-size: 10px; }
.workflow-action-editor header .workflow-mini-icon { width: 24px; height: 24px; }
.workflow-drag-handle { color: var(--muted); font-size: 14px; cursor: grab; }

.workflow-action-editor header button {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
}

.workflow-action-editor header button:hover { color: var(--rose); }
.workflow-action-editor label { padding: 10px; }
.workflow-action-editor textarea { min-height: 76px; resize: vertical; }

.workflow-buttons-editor {
  display: grid;
  gap: 9px;
  padding: 0 10px 10px;
}

.workflow-branch-editor {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, #31c6a1 28%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, #31c6a1 4%, var(--panel));
}

.workflow-branch-editor > header { background: color-mix(in srgb, #31c6a1 8%, var(--panel)); }
.workflow-branch-editor > header span:first-child { color: #22a985; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.workflow-branch-editor > label { padding: 9px; }

.workflow-branch-action-palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 0 9px 8px;
}

.workflow-branch-action-palette button,
.workflow-add-branch-button {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--muted);
  font-size: 8px;
}

.workflow-branch-actions { display: grid; gap: 6px; padding: 0 9px 9px; }

.workflow-branch-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22px;
  gap: 6px;
  align-items: end;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--input);
}

.workflow-branch-action label { padding: 0; }
.workflow-branch-action button { width: 22px; height: 30px; border: 0; background: transparent; color: var(--muted); }
.workflow-branch-action button:hover { color: var(--rose); }
.workflow-add-branch-button { width: 100%; border-style: dashed; color: #22a985; }

.workflow-branch-map {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(760px, calc(100vw - 460px));
  min-width: 520px;
  padding-top: 42px;
}

.workflow-branch-map::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 42px;
  background: #31c6a1;
  content: "";
}

.workflow-branch-grid {
  position: relative;
  display: grid;
  width: 100%;
  gap: 18px;
}

.workflow-branch-grid::before {
  position: absolute;
  top: 0;
  right: calc(100% / var(--branch-count) / 2);
  left: calc(100% / var(--branch-count) / 2);
  height: 2px;
  background: #31c6a1;
  content: "";
}

.workflow-branch-column {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  padding-top: 25px;
}

.workflow-branch-column::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 25px;
  background: #31c6a1;
  content: "";
}

.workflow-branch-label {
  max-width: 180px;
  padding: 6px 10px;
  border: 1px solid rgba(49, 198, 161, 0.55);
  border-radius: 999px;
  background: #18362f;
  color: #73e3c5;
  font-size: 9px;
  font-weight: 800;
}

.workflow-branch-node {
  display: grid;
  gap: 3px;
  width: min(190px, 100%);
  padding: 9px 10px;
  border: 1px solid #3a3e47;
  border-radius: 9px;
  background: #101216;
  color: #eef1f5;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.workflow-branch-node strong { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.workflow-branch-node small { color: #8f96a3; font-size: 8px; }

.workflow-actions-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.workflow-actions-empty strong { color: var(--ink); font-size: 11px; }
.workflow-actions-empty span { font-size: 9px; }

.workflow-inspector-help {
  margin: 14px 16px 0;
  padding: 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

@media (max-width: 1240px) {
  .workflow-builder { grid-template-columns: 205px minmax(420px, 1fr) 286px; }
  .workflow-stage { padding-right: 70px; padding-left: 70px; }
}

@media (max-width: 920px) {
  .automation-view { overflow: auto; }
  .workflow-builder-topbar { position: sticky; top: 0; flex-wrap: wrap; }
  .workflow-builder-heading { flex: 1 1 300px; }
  .workflow-builder-actions { flex: 1 1 auto; justify-content: flex-end; }
  .workflow-builder { grid-template-columns: 1fr; overflow: visible; }
  .workflow-library { max-height: 230px; border-right: 0; border-bottom: 1px solid var(--line); }
  .workflow-canvas-panel { min-height: 660px; }
  .workflow-inspector { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 560px) {
  .workflow-builder-topbar { padding: 10px; }
  .workflow-back-mark { display: none; }
  .workflow-publish-status { margin-left: auto; }
  .workflow-builder-actions { display: grid; grid-template-columns: 1fr 1fr 1.35fr; width: 100%; }
  .workflow-builder-actions .secondary-button,
  .workflow-builder-actions .send-button { min-width: 0; padding: 0 7px; font-size: 10px; }
  .workflow-stage { padding: 42px 28px 100px; }
  .workflow-node { width: min(300px, calc(100vw - 58px)); }
}
.workflow-live-dot.is-blocked { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 12%, transparent); }

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page-glow), var(--page);
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

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

.startup-error {
  display: grid;
  grid-column: 1 / -1;
  align-content: center;
  justify-items: start;
  gap: 14px;
  max-width: 620px;
  margin: auto;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.startup-error h1,
.startup-error p {
  margin: 0;
}

.startup-error > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.6;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 28%), color-mix(in srgb, var(--nav) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--nav-text);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.brand-mark {
  display: grid;
  position: relative;
  width: 48px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: linear-gradient(145deg, #fffdf2, #dff3eb);
  color: #102f26;
  box-shadow: 0 14px 26px rgba(2, 12, 9, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.78);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.brand-mark:hover {
  transform: translateY(-2px) rotate(-2deg);
  box-shadow: 0 18px 30px rgba(2, 12, 9, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.brand-sun {
  position: absolute;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f3b743;
  box-shadow: 0 0 0 5px rgba(243, 183, 67, 0.16);
  animation: sun-glow 3.2s ease-in-out infinite;
}

.brand-word {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.rail-button,
.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.rail-button::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: -10px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--amber);
  content: "";
  transition: transform var(--transition-fast);
}

.rail-button:hover,
.rail-button.active {
  background: rgba(255, 255, 255, 0.12);
}

.rail-button.active {
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.rail-button.active::before {
  transform: translateX(10px);
}

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

button:active {
  transform: translateY(1px) scale(0.98);
}

.rail-button.bottom {
  margin-top: auto;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-soft) 18%, transparent), transparent 50%), color-mix(in srgb, var(--panel) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.02);
  z-index: 5;
}

.eyebrow,
.section-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'Manrope', sans-serif;
}

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

h1,
h2,
h3 {
  font-family: 'Manrope', sans-serif;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: var(--soft-shadow);
}

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

.status-dot.connected {
  background: var(--accent);
  animation: connection-pulse 2.2s ease-in-out infinite;
}

.icon-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(18, 31, 27, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.icon-button:hover,
.secondary-button:hover {
  border-color: #bfd0c8;
  background: var(--card-hover);
}

.theme-toggle .sun-icon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

.inbox-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr) minmax(260px, 330px);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.inbox-grid[hidden],
.dashboard-view[hidden],
.contacts-view[hidden],
.pipeline-view[hidden],
.automation-view[hidden],
.auth-gate[hidden] {
  display: none;
}

.auth-gate {
  display: grid;
  position: relative;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: #0c1c17 url("/assets/padel-chat-bg.webp") center / cover;
}

.auth-gate::before {
  position: absolute;
  inset: 0;
  background: rgba(5, 17, 13, 0.72);
  content: "";
}

.auth-card {
  display: grid;
  position: relative;
  z-index: 1;
  width: min(390px, 100%);
  gap: 20px;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(10, 31, 24, 0.76);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 32px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #f4fcf7;
  animation: auth-card-arrive 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes auth-card-arrive {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #c5ded2;
  font-size: 13px;
  font-weight: 700;
}

.auth-card h1 {
  margin: 2px 0 0;
  font-size: 27px;
}

.auth-copy,
.auth-footnote {
  margin: 8px 0 0;
  color: #c5ded2;
  font-size: 13px;
  line-height: 1.5;
}

.auth-card label,
.modal-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-card input,
.modal-label select {
  min-height: 42px;
  padding: 0 10px;
}

.auth-card input {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(5, 15, 12, 0.44);
  color: #f4fcf7;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-card input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(83, 220, 165, 0.25);
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid rgba(226, 246, 236, 0.18);
  border-radius: 8px;
  background: rgba(5, 17, 13, 0.42);
}

.auth-switch:has([data-auth-mode="register"][hidden]) {
  grid-template-columns: 1fr;
}

.auth-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c5ded2;
  font-size: 13px;
  font-weight: 800;
}

.auth-switch button.active {
  background: #effbf5;
  color: #133329;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: #a9c5b8;
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  background: rgba(226, 246, 236, 0.2);
  content: "";
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid rgba(226, 246, 236, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: #26332e;
  font-size: 14px;
  font-weight: 800;
}

.google-button:hover:not(:disabled) {
  background: #f4f7f5;
}

.google-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.google-mark {
  color: #4285f4;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
}

.auth-footnote {
  margin: -4px 0 0;
  text-align: center;
}

.form-error {
  margin: -6px 0 0;
  color: var(--rose);
  font-size: 13px;
}

.form-success,
.connection-result {
  margin: 0;
  color: var(--accent-strong);
  font-size: 13px;
  line-height: 1.45;
}

.connection-result.error {
  color: var(--rose);
}

.auth-link {
  border: 0;
  background: transparent;
  color: #c5ded2;
  font-size: 13px;
  text-align: center;
  text-decoration: underline;
}

.pipeline-view,
.automation-view {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  background: var(--page);
}

.bot-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  overflow: auto;
  padding: 28px;
  background: var(--page);
}

.bot-heading,
.bot-tester-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.bot-heading h2 {
  margin-bottom: 6px;
}

.bot-heading p,
.bot-tester-header small {
  margin: 0;
  color: var(--muted);
}

.automation-status.is-muted {
  border-color: var(--line);
  background: var(--card-hover);
  color: var(--muted);
}

.bot-tester {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  width: min(860px, 100%);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  overflow: hidden;
}

.bot-tester-header {
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.bot-tester-header > div {
  display: grid;
  gap: 3px;
}

.bot-test-messages {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 18px;
  background: color-mix(in srgb, var(--page) 55%, var(--panel));
}

.bot-test-message {
  display: grid;
  gap: 5px;
  max-width: min(680px, 88%);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.bot-test-message.user {
  justify-self: end;
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: var(--message-out);
}

.bot-test-message > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.bot-test-message p {
  margin: 0;
  line-height: 1.5;
}

.bot-test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.bot-test-actions .secondary-button {
  min-height: 31px;
  padding: 0 9px;
  font-size: 12px;
  text-decoration: none;
}

.bot-test-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 220px;
  gap: 5px;
  color: var(--muted);
  text-align: center;
}

.bot-test-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.bot-test-composer textarea {
  min-height: 44px;
  max-height: 120px;
  padding: 10px;
  resize: vertical;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  min-width: 920px;
}

.pipeline-column {
  min-height: 360px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--soft-shadow);
}

.pipeline-column > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pipeline-column h3 {
  margin: 0;
  font-size: 14px;
}

.pipeline-column header span,
.automation-status {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.pipeline-column > div {
  display: grid;
  gap: 8px;
}

.pipeline-card {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.pipeline-card:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
  background: var(--card-hover);
}

.pipeline-card span,
.pipeline-card small,
.pipeline-empty,
.automation-card p {
  color: var(--muted);
  font-size: 12px;
}

.pipeline-empty {
  margin: 16px 0;
  text-align: center;
}

.automation-list {
  display: grid;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}

.automation-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.automation-card p {
  margin: 5px 0 0;
}

.profile-actions {
  display: grid;
  gap: 8px;
}

.danger-button {
  width: 100%;
  min-height: 36px;
  border: 1px solid color-mix(in srgb, var(--rose) 60%, var(--line));
  border-radius: 8px;
  background: transparent;
  color: var(--rose);
}

.settings-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.message-attachment {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.toast.error {
  border-color: var(--rose);
}

.dashboard-view {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  background: var(--page);
}

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 24px;
  max-width: 1240px;
}

.dashboard-heading h2,
.dashboard-section h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.dashboard-heading > div > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dashboard-updated {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 1240px;
  margin: 0 auto 20px;
}

.metric-card {
  min-height: 136px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.dashboard-content {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.85fr);
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
}

.dashboard-section {
  min-height: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.dashboard-section > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.dashboard-section > header > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.volume-section {
  min-height: 360px;
}

.pipeline-section {
  min-height: 176px;
}

.activity-section {
  grid-column: 1 / -1;
}

.volume-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(32px, 1fr));
  align-items: end;
  gap: 12px;
  height: 245px;
  padding: 12px 0 0;
  border-bottom: 1px solid var(--line);
}

.chart-day {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 9px;
  height: 100%;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.chart-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  min-height: 0;
}

.chart-bar {
  width: min(16px, 34%);
  min-height: 4px;
  border-radius: 4px 4px 0 0;
}

.chart-bar.incoming,
.legend-incoming {
  background: var(--accent);
}

.chart-bar.outgoing,
.legend-outgoing {
  background: var(--amber);
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}

.stage-list {
  display: grid;
  gap: 14px;
}

.stage-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stage-row > div {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--accent-soft);
}

.stage-row i {
  display: block;
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.stage-row strong {
  color: var(--ink);
  text-align: right;
}

.activity-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-contact {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.activity-contact:hover {
  border-color: var(--line);
  background: var(--card-hover);
}

.activity-contact .avatar {
  width: 36px;
  height: 36px;
  font-size: 12px;
}

.activity-contact strong,
.activity-contact small,
.activity-contact time {
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-contact small,
.activity-contact time,
.activity-empty {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.contacts-view {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  background: var(--page);
}

.contacts-heading,
.contacts-toolbar,
.contacts-table-wrap {
  max-width: 1240px;
  margin-right: auto;
  margin-left: auto;
}

.contacts-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.contacts-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contacts-heading h2 {
  margin: 0;
  font-size: 20px;
}

.contacts-heading p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.contacts-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px;
  gap: 10px;
  margin-bottom: 14px;
}

.contacts-search {
  height: 38px;
}

.contacts-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.contacts-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 13px;
}

.contacts-table th,
.contacts-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.contacts-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card-hover);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.contacts-table tbody tr:last-child td {
  border-bottom: 0;
}

.contacts-table tbody tr:hover td {
  background: var(--card-hover);
}

.contact-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 300px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.contact-link .avatar {
  width: 34px;
  height: 34px;
  font-size: 11px;
}

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

.contact-link strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.contact-link small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.contacts-empty {
  height: 180px;
  color: var(--muted);
  text-align: center !important;
}

.lead-column,
.conversation-column,
.profile-panel {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lead-column,
.conversation-column,
.profile-panel {
  box-shadow: var(--shadow);
}

.lead-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.filters {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--input);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--panel));
}

.segmented button {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.segmented button.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(14, 27, 23, 0.08);
}

.conversation-filter {
  width: 100%;
  font-size: 13px;
}

.segment-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  font-size: 12px;
}

.segment-control input[type="checkbox"] { width: 18px; height: 18px; flex-shrink: 0; }
.segment-reason { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }

.lead-list {
  overflow: auto;
  padding: 8px;
}

.lead-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.lead-card:hover,
.lead-card.active {
  border-color: var(--line);
  background: var(--card-hover);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

.lead-card.priority {
  border-color: color-mix(in srgb, #d88618 44%, var(--line));
}

.lead-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.priority-star {
  color: #d88618;
  font-size: 17px;
  line-height: 1;
  text-shadow: 0 1px 6px color-mix(in srgb, #d88618 38%, transparent);
}

.lead-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lead-card.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent-soft) 58%, transparent), transparent 70%),
    var(--card-hover);
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 72% 22%, rgba(246, 183, 60, 0.88) 0 16%, transparent 17%),
    linear-gradient(145deg, var(--accent-soft), color-mix(in srgb, var(--accent) 18%, var(--panel)));
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0;
}

.avatar.large {
  width: 52px;
  height: 52px;
}

.lead-card h3 {
  overflow: hidden;
  margin: 0 0 3px;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.lead-card p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.channel-badge,
.stage-badge,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft) 52%, var(--panel));
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.channel-badge.whatsapp {
  background: #def4ea;
  color: #0f674d;
}

.channel-badge.instagram {
  background: #f7e5ec;
  color: var(--rose);
}

.channel-badge.webchat {
  background: #e4eef4;
  color: var(--steel);
}

.channel-badge.planned {
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  background: color-mix(in srgb, var(--panel) 82%, var(--accent-soft));
  color: var(--muted);
}

.conversation-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.lead-title {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lead-title h2 {
  overflow: hidden;
  margin: 0 0 2px;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-title p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.conversation-actions select {
  max-width: 126px;
}

.channel-badge-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.conversation-actions .icon-button.is-priority {
  border-color: #d88618;
  background: #fff3dc;
  color: #a85d00;
}

:root[data-theme="dark"] .conversation-actions .icon-button.is-priority {
  background: #4a351b;
  color: #ffd28a;
}

.conversation-actions .icon-button.is-closed {
  border-color: #df4d5e;
  background: #fff0f2;
  color: #bd283d;
}

:root[data-theme="dark"] .conversation-actions .icon-button.is-closed {
  border-color: #db5667;
  background: #4d252d;
  color: #ffabb7;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select {
  height: 38px;
  padding: 0 10px;
}

.message-timeline {
  overflow: auto;
  display: flex;
  position: relative;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background:
    var(--timeline-wash),
    url("/assets/padel-chat-bg.webp") center / cover no-repeat;
}

.empty-state {
  display: grid;
  position: relative;
  min-height: 100%;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.conversation-empty {
  align-content: center;
  min-height: min(320px, 58%);
  margin: 28px;
  padding: 32px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 46%, var(--panel)), var(--panel));
  box-shadow: var(--soft-shadow);
}

.conversation-empty strong {
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.conversation-empty p {
  max-width: 270px;
  margin: 8px auto 0;
  font-size: 13px;
  line-height: 1.65;
}

.message {
  position: relative;
  max-width: min(72%, 620px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--message-in);
  backdrop-filter: blur(4px);
  box-shadow: var(--soft-shadow);
  animation: none;
}

@keyframes message-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.out {
  align-self: flex-end;
  border-color: rgba(83, 220, 165, 0.16);
  background: var(--message-out);
}

.message p {
  margin: 0;
  white-space: pre-wrap;
}

.message span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.composer {
  display: grid;
  grid-template-columns: repeat(4, 42px) minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 82%, transparent), var(--panel)),
    var(--panel);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 130px;
  resize: vertical;
  padding: 10px 12px;
  outline: 0;
}

.composer > .send-button {
  min-width: 112px;
  white-space: nowrap;
}

.composer.internal-mode {
  background: color-mix(in srgb, #f59e0b 10%, var(--panel));
}

.icon-button.is-active {
  color: #fff;
  background: #b45309;
  border-color: #b45309;
}

.attachment-preview {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.attachment-preview button {
  min-height: 0;
  padding: 0 3px;
  color: inherit;
  font-size: 18px;
}

.message.internal {
  align-self: center;
  width: min(90%, 620px);
  max-width: 620px;
  border-style: dashed;
  border-color: rgba(245, 158, 11, .5);
  background: color-mix(in srgb, #f59e0b 11%, var(--panel));
}

.internal-note-label,
.message-mentions {
  display: block;
  color: #b45309;
  font-size: 11px;
}

.message-attachment {
  overflow-wrap: anywhere;
}

.tag-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.tag-editor input { min-width: 0; }
.tag-editor .secondary-button { width: auto; min-height: 34px; padding: 0 10px; }
.removable-tag { cursor: pointer; }

.composer.disabled {
  opacity: 0.76;
}

.composer.disabled textarea,
.composer.disabled button {
  cursor: not-allowed;
}

.send-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.send-button {
  background:
    linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 22px color-mix(in srgb, var(--accent) 26%, transparent);
}

.send-button:hover {
  background: var(--accent-strong);
}

.send-button.wide {
  width: 100%;
  margin-top: 16px;
}

.secondary-button {
  width: 100%;
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

.profile-panel {
  overflow: auto;
  border-right: 0;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.profile-head {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.profile-head h3 {
  overflow: hidden;
  margin: 0 0 3px;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-head p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-fields {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.profile-fields div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.profile-fields dt {
  color: var(--muted);
  font-size: 13px;
}

.profile-fields dd {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notes-input {
  width: 100%;
  min-height: 110px;
  margin-bottom: 10px;
  padding: 10px;
  resize: vertical;
}

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

.routing-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-hover);
  font-size: 13px;
}

.routing-list .ai-consent-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-hover);
  font-size: 13px;
}

.ai-consent-control input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.modal {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
  background: var(--panel);
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(12, 22, 19, 0.48);
}

.modal > form,
.workspace-settings {
  padding: 18px;
}

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

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

.logout-button {
  color: var(--rose);
}

.modal h2 {
  margin: 0;
  font-size: 20px;
}

.import-dialog {
  width: min(760px, calc(100vw - 32px));
}

.import-file-field {
  display: grid;
  gap: 7px;
  margin: 16px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.import-file-field input {
  min-height: 42px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--card-hover);
  color: var(--muted);
}

.import-summary {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.import-preview {
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-hover);
}

.import-preview:empty {
  display: none;
}

.import-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.import-preview th,
.import-preview td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

#respondIoMigrationPreview td:first-child {
  min-width: 110px;
  max-width: 180px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.import-preview th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.import-preview p {
  margin: 9px 10px;
  color: var(--muted);
  font-size: 12px;
}

.setup-grid,
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setup-grid.compact {
  margin-top: 14px;
}

.settings-section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.bot-settings {
  padding-top: 16px;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.form-span {
  grid-column: 1 / -1;
}

.setup-grid code {
  display: block;
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-hover);
}

.check-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.modal-copy {
  margin: 16px 0 0;
  color: var(--muted);
}

.owners-settings {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.workspace-settings {
  border-top: 1px solid var(--line);
}

.invite-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px auto;
  gap: 8px;
  margin: 12px 0;
}

.invite-form input,
.invite-form select,
.member-row select {
  min-height: 40px;
  padding: 0 10px;
}

.member-list,
.invitation-list {
  display: grid;
  gap: 8px;
}

.invitation-list:not(:empty) {
  margin-top: 12px;
}

.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-hover);
}

.member-row span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.member-row small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
}

.member-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.member-controls,
.member-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.compact-button {
  min-height: 36px;
  padding: 0 10px;
}

.settings-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-section-heading .section-label {
  margin: 0;
}

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

.owner-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.owner-row input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.phone-field {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(132px, 0.36fr) minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.phone-field legend {
  grid-column: 1 / -1;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.phone-field label {
  min-width: 0;
}

.form-grid input,
.form-grid select {
  width: 100%;
  height: 40px;
  padding: 0 10px;
}

.form-grid input.is-invalid {
  border-color: #d14343;
  background: #fff5f5;
  box-shadow: 0 0 0 1px #d14343;
}

:root[data-theme="dark"] .form-grid input.is-invalid {
  background: #3b2224;
}

/* Visual rhythm and feedback for the working surfaces. */
html {
  background: var(--page);
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: var(--ink);
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 24%, transparent) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 24%, transparent);
}

*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 58%, transparent);
}

*::-webkit-scrollbar-track {
  background: transparent;
}

.inbox-grid {
  background: var(--surface-muted);
}

.lead-column,
.conversation-column,
.profile-panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.filters,
.conversation-header,
.composer {
  background: color-mix(in srgb, var(--panel) 93%, var(--surface-muted));
}

.filters {
  gap: 11px;
}

.search-box,
.conversation-filter,
.conversation-actions select,
select,
input,
textarea {
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.search-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 68%, var(--line));
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--focus-ring), inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

select:hover,
input:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--muted) 52%, var(--line));
}

.segmented {
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--panel));
}

.segmented button {
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.segmented button:not(:disabled):hover {
  color: var(--ink);
}

.segmented button.active {
  box-shadow: 0 3px 10px rgba(14, 27, 23, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.lead-list {
  padding: 10px 8px;
}

.lead-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.lead-card::after {
  position: absolute;
  z-index: -1;
  inset: 0 14px auto;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 999px 999px;
  content: "";
  transform: scaleX(0);
  transform-origin: center;
  transition: transform var(--transition-fast);
}

.lead-card.active::after {
  transform: scaleY(1);
}

.lead-card:hover,
.lead-card.active {
  box-shadow: 0 12px 22px rgba(18, 31, 27, 0.09);
}

.unread-count {
  box-shadow: 0 4px 10px color-mix(in srgb, var(--accent-strong) 34%, transparent);
}

.avatar {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.lead-card:hover .avatar,
.activity-contact:hover .avatar,
.contact-link:hover .avatar {
  transform: scale(1.05) rotate(-2deg);
  box-shadow: 0 7px 14px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.conversation-header {
  box-shadow: 0 2px 16px rgba(18, 31, 27, 0.025);
}

.message-timeline {
  background-color: var(--surface-muted);
}

.message {
  animation: message-arrive 360ms var(--transition-smooth) both;
}

.message.out {
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 12%, transparent);
}

.composer {
  box-shadow: 0 -5px 20px rgba(18, 31, 27, 0.035);
}

.composer:focus-within {
  background: var(--panel);
}

.send-button,
.secondary-button,
.danger-button,
.google-button {
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}

.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 26px color-mix(in srgb, var(--accent) 34%, transparent);
}

.send-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.52;
}

.secondary-button:hover:not(:disabled),
.danger-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

.panel-section {
  transition: background var(--transition-fast);
}

.panel-section:hover {
  background: color-mix(in srgb, var(--panel) 90%, var(--accent-soft));
}

.routing-list div {
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.routing-list div:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--panel);
  transform: translateX(2px);
}

.dashboard-view,
.contacts-view,
.pipeline-view,
.automation-view {
  background: var(--surface-muted);
}

.dashboard-heading h2,
.contacts-heading h2 {
  position: relative;
  padding-bottom: 8px;
}

.dashboard-heading h2::before,
.contacts-heading h2::before {
  position: absolute;
  right: auto;
  bottom: 0;
  left: 0;
  width: 36px;
  height: 3px;
  border-radius: 999px;
  background: var(--amber);
  content: "";
}

.metric-card,
.dashboard-section,
.contacts-table-wrap,
.pipeline-column,
.automation-card {
  border-color: color-mix(in srgb, var(--line) 82%, var(--accent-soft));
  background: var(--panel);
}

.metric-card {
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-fast);
}

.metric-card::before {
  position: absolute;
  top: 0;
  right: 18px;
  left: 18px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--accent);
  content: "";
}

.metric-card:nth-child(2)::before { background: var(--amber); }
.metric-card:nth-child(3)::before { background: var(--steel); }
.metric-card:nth-child(4)::before { background: var(--rose); }

.metric-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: 0 16px 32px rgba(18, 31, 27, 0.11);
  transform: translateY(-3px);
}

.dashboard-section {
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-fast);
}

.dashboard-section:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  box-shadow: 0 16px 32px rgba(18, 31, 27, 0.09);
}

.volume-chart {
  background: repeating-linear-gradient(to bottom, transparent 0 48px, color-mix(in srgb, var(--line) 55%, transparent) 49px 50px);
}

.chart-bar {
  animation: chart-rise 560ms var(--transition-smooth) both;
  transform-origin: bottom;
}

.chart-day:nth-child(2) .chart-bar { animation-delay: 45ms; }
.chart-day:nth-child(3) .chart-bar { animation-delay: 90ms; }
.chart-day:nth-child(4) .chart-bar { animation-delay: 135ms; }
.chart-day:nth-child(5) .chart-bar { animation-delay: 180ms; }
.chart-day:nth-child(6) .chart-bar { animation-delay: 225ms; }
.chart-day:nth-child(7) .chart-bar { animation-delay: 270ms; }

.stage-row i {
  animation: stage-grow 620ms var(--transition-smooth) both;
  transform-origin: left;
}

.contacts-table tbody tr {
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.contacts-table tbody tr:hover {
  transform: translateX(2px);
}

.pipeline-card,
.automation-card,
.activity-contact {
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.pipeline-card:hover,
.automation-card:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  box-shadow: var(--soft-shadow);
  transform: translateY(-2px);
}

.automation-status {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.modal {
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
}

.modal[open] {
  animation: dialog-arrive 380ms var(--transition-emphasis) both;
}

.modal[open]::backdrop {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdrop-fade 300ms ease both;
}

.modal header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.toast:not([hidden]) {
  animation: toast-arrive 300ms var(--transition-smooth) both;
}

.auth-gate::before {
  background: linear-gradient(110deg, rgba(5, 17, 13, 0.84), rgba(5, 17, 13, 0.64));
}

.auth-card {
  background: rgba(12, 31, 25, 0.94);
  animation: auth-arrive 540ms var(--transition-smooth) both;
}

.auth-card .brand-mark {
  flex: 0 0 auto;
}

.auth-switch button {
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.auth-switch button.active {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.auth-card input:focus {
  border-color: color-mix(in srgb, #8df0c6 72%, #ffffff);
  box-shadow: 0 0 0 3px rgba(83, 220, 165, 0.18);
}

@keyframes sun-glow {
  0%, 100% { box-shadow: 0 0 0 5px rgba(243, 183, 67, 0.16); }
  50% { box-shadow: 0 0 0 8px rgba(243, 183, 67, 0.08); }
}

@keyframes connection-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 48%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
}

@keyframes message-arrive {
  from { opacity: 0; transform: translateY(7px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes chart-rise {
  from { transform: scaleY(0.04); }
  to { transform: scaleY(1); }
}

@keyframes stage-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes dialog-arrive {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes backdrop-fade {
  from { background: rgba(0, 0, 0, 0); }
  to { background: rgba(0, 0, 0, 0.55); }
}

@keyframes toast-arrive {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-arrive {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@media (max-width: 1100px) {
  .inbox-grid {
    grid-template-columns: minmax(260px, 340px) minmax(360px, 1fr);
  }

  .profile-panel {
    display: none;
  }

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

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

  .activity-section {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .pipeline-view,
  .automation-view {
    padding: 16px;
  }

  .pipeline-board {
    grid-template-columns: repeat(4, minmax(210px, 1fr));
  }

  .automation-card {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-actions {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .nav-rail {
    position: static;
    z-index: 2;
    flex-direction: row;
    justify-content: center;
    min-height: 58px;
    padding: 6px 8px;
  }

  .rail-button.bottom {
    margin-top: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    padding: 10px 12px;
  }

  .inbox-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(132px, 24vh) minmax(0, 1fr);
    min-height: 0;
  }

  .dashboard-view {
    padding: 18px 14px;
  }

  .contacts-view {
    padding: 18px 14px;
  }

  .contacts-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .contacts-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .contacts-search {
    grid-column: 1 / -1;
  }

  .dashboard-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    min-height: 116px;
    padding: 14px;
  }

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

  .dashboard-section {
    padding: 16px;
  }

  .volume-section {
    min-height: 310px;
  }

  .volume-chart {
    gap: 6px;
    height: 200px;
  }

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

  .lead-column {
    max-height: none;
    min-height: 0;
    border-bottom: 1px solid var(--line);
  }

  .conversation-column {
    min-height: 0;
  }

  .conversation-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .conversation-actions {
    width: 100%;
  }

  .conversation-actions select {
    flex: 1 1 0;
    min-width: 0;
  }

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

  .bot-view {
    padding: 18px 14px;
  }

  .bot-heading,
  .bot-tester-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .bot-test-composer {
    grid-template-columns: 1fr;
  }

  .phone-field {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 42px 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 8px;
    padding: 10px;
  }

  .composer textarea {
    min-height: 40px;
    max-height: 82px;
  }

  .composer > .send-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .send-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Final cascade: modern operations center */

body {
  background: var(--page-glow), var(--page);
}

.app-shell {
  grid-template-columns: 190px minmax(0, 1fr);
  background: var(--page);
}

.nav-rail {
  align-items: stretch;
  gap: 4px;
  padding: 14px 12px 12px;
  overflow: hidden auto;
  border-right: 1px solid rgba(139, 158, 193, 0.17);
  background: radial-gradient(circle at 12% 0, rgba(53, 205, 148, 0.2), transparent 25%), linear-gradient(180deg, #0a261e 0%, var(--nav) 58%, #06110d 100%);
  box-shadow: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-color: rgba(168, 255, 219, 0.38);
  border-radius: 10px;
  background: linear-gradient(145deg, #39d3a0, #087556);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(5, 107, 75, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 5px;
  margin-bottom: 8px;
}

.brand-mark {
  flex: 0 0 38px;
}

.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-copy strong {
  color: #ffffff;
  font-size: 14px;
  letter-spacing: 0.08em;
}

.brand-copy span {
  color: #9fb9ad;
  font-size: 10px;
}

.workspace-switcher {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 7px;
  border: 1px solid rgba(129, 148, 182, 0.2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--nav-text);
}

.workspace-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: linear-gradient(135deg, #1c4b3b, #2d7057);
  color: #e2fff0;
  font-size: 9px;
  font-weight: 850;
}

.workspace-switcher > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.workspace-switcher strong,
.workspace-switcher small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-switcher strong {
  font-size: 12px;
}

.workspace-switcher small {
  color: #93aca1;
  font-size: 10px;
}

.workspace-switcher svg {
  width: 14px;
  height: 14px;
  color: #71809a;
}

.rail-section-label {
  margin: 11px 8px 5px;
  color: #86a397;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-sun {
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: #7ef0ca;
  box-shadow: 0 0 0 4px rgba(126, 240, 202, 0.12);
}

.brand-word {
  margin-top: 0;
  font-size: 17px;
}

.rail-button {
  grid-template-columns: 20px minmax(0, 1fr) auto;
  justify-content: stretch;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  overflow: visible;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #93a1b8;
}

.rail-button::before {
  top: 8px;
  bottom: 8px;
  left: -12px;
  width: 3px;
  background: #39d3a0;
  opacity: 0;
  transform: scaleY(0.35);
}

.rail-button:hover {
  border-color: rgba(146, 164, 196, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #e5ebf5;
  transform: none;
}

.rail-button.active {
  border-color: rgba(54, 201, 152, 0.26);
  background: linear-gradient(90deg, rgba(30, 183, 129, 0.28), rgba(30, 183, 129, 0.08));
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.rail-button.active::before {
  opacity: 1;
  transform: scaleY(1);
}

.rail-button.bottom {
  margin-top: 0;
}

.rail-label {
  overflow: hidden;
  font-size: 11px;
  font-weight: 650;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-badge {
  padding: 2px 5px;
  border: 1px solid rgba(121, 235, 194, 0.18);
  border-radius: 999px;
  background: rgba(47, 208, 151, 0.12);
  color: #76e1bb;
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
}

.rail-badge.new {
  border-color: rgba(192, 163, 255, 0.2);
  background: rgba(151, 112, 242, 0.13);
  color: #c7afff;
}

.conversation-reply-badge {
  display: inline-grid;
  min-width: 19px;
  height: 19px;
  place-items: center;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.35);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

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

.rail-system-state {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 11px 9px 7px;
  border-top: 1px solid rgba(128, 148, 182, 0.14);
}

.rail-system-state .status-dot {
  width: 7px;
  height: 7px;
}

.rail-system-state > span:last-child {
  display: grid;
}

.rail-system-state strong {
  color: #b9c5d6;
  font-size: 9px;
}

.rail-system-state small {
  color: #64728a;
  font-size: 8px;
}

.workspace {
  grid-template-rows: 72px minmax(0, 1fr);
  background: var(--page);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 10px 18px;
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: none;
  backdrop-filter: blur(18px);
}

.topbar h1 {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.topbar-heading {
  min-width: 0;
}

.topbar-heading .eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 9px;
  letter-spacing: 0.11em;
}

.live-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #41d6a0;
  box-shadow: 0 0 0 4px rgba(65, 214, 160, 0.1);
}

.topbar-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.topbar-metrics {
  display: flex;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  overflow: hidden;
}

.topbar-metric {
  display: grid;
  grid-template-columns: 26px auto;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  padding: 6px 9px;
  border-right: 1px solid var(--line);
}

.topbar-metric:last-child {
  border-right: 0;
}

.topbar-metric > span:last-child {
  display: grid;
}

.topbar-metric small {
  color: var(--muted);
  font-size: 7px;
  font-weight: 750;
  text-transform: uppercase;
}

.topbar-metric strong {
  font-size: 12px;
}

.metric-signal {
  display: block;
  width: 26px;
  height: 20px;
  background: currentColor;
  clip-path: polygon(0 72%, 10% 42%, 20% 62%, 30% 26%, 40% 54%, 50% 16%, 60% 60%, 70% 35%, 80% 68%, 90% 18%, 100% 45%, 100% 100%, 0 100%);
  opacity: 0.82;
}

.metric-signal.violet { color: #9b7cff; }
.metric-signal.blue { color: #55b9ff; }
.metric-signal.pink { color: #ed6fbd; }

.connection-pill {
  min-height: 34px;
  border-radius: 8px;
  background: var(--surface-raised);
  box-shadow: none;
  font-size: 10px;
}

.inbox-grid {
  grid-template-columns: minmax(250px, 280px) minmax(390px, 1fr) minmax(238px, 260px);
  gap: 8px;
  padding: 8px;
  background: var(--page);
}

.lead-column,
.conversation-column,
.profile-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: none;
}

.profile-panel {
  overflow: auto;
  border-right: 1px solid var(--line);
}

.filters,
.conversation-header,
.composer {
  background: var(--panel);
}

.filters {
  gap: 9px;
  padding: 12px;
}

.search-box {
  height: 38px;
  border-radius: 7px;
  background: var(--input);
  box-shadow: none;
}

.segmented {
  height: 32px;
  border: 0;
  border-radius: 7px;
  background: var(--input);
}

.segmented button.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
}

.lead-card {
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 86px;
  padding: 10px;
  border-radius: 8px;
}

.lead-card:hover,
.lead-card.active {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background: color-mix(in srgb, var(--card-hover) 82%, var(--accent-soft));
  box-shadow: none;
  transform: none;
}

.lead-card.active {
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent-soft) 66%, var(--panel)), var(--panel));
}

.avatar {
  width: 38px;
  height: 38px;
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: 10px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent-soft) 88%, var(--panel)), color-mix(in srgb, var(--accent) 26%, var(--panel)));
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.channel-badge,
.stage-badge,
.tag {
  min-height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 9px;
}

:root[data-theme="dark"] .channel-badge.whatsapp {
  background: rgba(48, 205, 149, 0.12);
  color: #69dbae;
}

.conversation-header {
  min-height: 64px;
  padding: 10px 13px;
  box-shadow: none;
}

.lead-title {
  flex: 1 1 150px;
}

.conversation-actions {
  flex: 0 1 auto;
}

.conversation-actions select {
  max-width: 94px;
  height: 32px;
  padding: 0 7px;
  font-size: 9px;
}

.message-timeline {
  gap: 8px;
  padding: 18px;
  background-color: var(--surface-muted);
}

.message {
  padding: 9px 11px;
  border-color: color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 10px 10px 10px 3px;
  font-size: 11px;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.13);
}

.message.out {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 10px 10px 3px 10px;
}

.composer {
  grid-template-columns: 36px 36px minmax(0, 1fr) auto;
  gap: 7px;
  padding: 10px;
  box-shadow: none;
}

.composer textarea {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
}

.composer > .send-button {
  min-width: 90px;
  min-height: 36px;
  font-size: 10px;
}

.send-button {
  background: linear-gradient(135deg, #8d6df5, #5b43cf);
  box-shadow: 0 8px 20px rgba(89, 65, 206, 0.24);
}

.dashboard-view,
.contacts-view,
.pipeline-view,
.automation-view,
.bot-view {
  background: var(--page);
}

.metric-card,
.dashboard-section,
.contacts-table-wrap,
.pipeline-column,
.automation-card,
.bot-tester {
  border-color: var(--line);
  border-radius: 10px;
  background-color: var(--panel);
  box-shadow: none;
}

.metric-card {
  background: radial-gradient(circle at 88% 5%, rgba(155, 124, 255, 0.2), transparent 38%), var(--panel);
}

.metric-card:nth-child(2) {
  background: radial-gradient(circle at 88% 5%, rgba(247, 184, 75, 0.18), transparent 38%), var(--panel);
}

.metric-card:nth-child(3) {
  background: radial-gradient(circle at 88% 5%, rgba(93, 196, 255, 0.18), transparent 38%), var(--panel);
}

.metric-card:nth-child(4) {
  background: radial-gradient(circle at 88% 5%, rgba(242, 116, 189, 0.18), transparent 38%), var(--panel);
}

.chart-bar.incoming,
.legend-incoming {
  background: linear-gradient(180deg, #a98dff, #674be0);
}

.chart-bar.outgoing,
.legend-outgoing {
  background: linear-gradient(180deg, #65cafb, #318fc9);
}

.stage-row i {
  background: linear-gradient(90deg, #7455e8, #bd73ee);
}

.auth-card {
  border-color: rgba(145, 125, 230, 0.28);
  border-radius: 14px;
  background: rgba(12, 22, 39, 0.92);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(20px);
}

@media (max-width: 1280px) {
  .topbar-metrics {
    display: none;
  }

  .topbar {
    grid-template-columns: minmax(210px, 1fr) auto;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .nav-rail {
    align-items: center;
    padding-right: 10px;
    padding-left: 10px;
  }

  .brand-copy,
  .workspace-switcher,
  .rail-section-label,
  .rail-label,
  .rail-badge,
  .rail-system-state > span:last-child {
    display: none;
  }

  .rail-button {
    grid-template-columns: 1fr;
    width: 42px;
    padding: 0;
    place-items: center;
  }

  .conversation-reply-badge {
    position: absolute;
    top: 2px;
    right: 1px;
  }

  .rail-system-state {
    grid-template-columns: 1fr;
    place-items: center;
    width: 42px;
    padding-right: 0;
    padding-left: 0;
  }

  .inbox-grid {
    grid-template-columns: minmax(250px, 305px) minmax(360px, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 58px minmax(0, 1fr);
  }

  .nav-rail {
    flex-direction: row;
    justify-content: flex-start;
    min-height: 58px;
    padding: 7px 8px;
    overflow: auto hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(139, 158, 193, 0.17);
  }

  .brand-lockup {
    margin: 0 4px 0 0;
    padding: 0;
  }

  .rail-system-state {
    display: none;
  }

  .workspace {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    display: flex;
    align-items: center;
    flex-direction: row;
    min-height: 66px;
    padding: 9px 12px;
  }

  .topbar-subtitle,
  .connection-pill {
    display: none;
  }

  .inbox-grid {
    gap: 6px;
    padding: 6px;
  }

  .lead-column,
  .conversation-column {
    border-radius: 8px;
  }
}

.workspace-switcher {
  width: 100%;
  font: inherit;
  text-align: left;
}

.workspace-switcher:hover {
  border-color: rgba(155, 124, 255, 0.38);
  background: rgba(155, 124, 255, 0.1);
}

.team-dialog {
  width: min(460px, calc(100vw - 28px));
  padding: 18px;
}

.team-dialog > header {
  margin-bottom: 8px;
}

.team-dialog > header .section-label {
  margin-bottom: 4px;
}

.team-dialog > header h2 {
  margin: 0;
  font-size: 19px;
}

.team-list {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.team-members-button {
  margin-bottom: 16px;
}

.team-leave-button {
  margin: 0 0 16px 8px;
}

@media (max-width: 620px) {
  .member-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .member-controls,
  .member-actions {
    justify-content: flex-start;
  }
}

.team-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--input);
  color: var(--ink);
  text-align: left;
}

.team-option:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 38%, var(--panel));
}

.team-option.active {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  background: linear-gradient(100deg, color-mix(in srgb, var(--accent-soft) 72%, var(--panel)), var(--panel));
}

.team-option .workspace-avatar {
  width: 34px;
  height: 34px;
}

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

.team-option strong,
.team-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-option strong {
  font-size: 12px;
}

.team-option small {
  color: var(--muted);
  font-size: 10px;
}

.team-option em {
  padding: 3px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-soft) 75%, transparent);
  color: var(--accent);
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
}

.team-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.team-create-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.team-create-form input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
}

.team-create-form .send-button {
  align-self: end;
  min-height: 38px;
  padding: 0 12px;
  font-size: 10px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .team-dialog {
    padding: 14px;
  }

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

/* Visual motion layer */
.workspace {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.workspace::before,
.workspace::after {
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  content: "";
  filter: blur(4px);
}

.workspace::before {
  top: -18rem;
  right: -10rem;
  width: 38rem;
  height: 38rem;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 17%, transparent) 0%, transparent 68%);
  animation: none;
}

.workspace::after {
  bottom: -24rem;
  left: 20%;
  width: 34rem;
  height: 34rem;
  background: radial-gradient(circle, rgba(56, 166, 232, 0.12) 0%, transparent 68%);
  animation: none;
}

:root[data-theme="dark"] .workspace::after {
  background: radial-gradient(circle, rgba(93, 196, 255, 0.1) 0%, transparent 68%);
}

.topbar {
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.topbar::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(34vw, 480px);
  background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--accent) 8%, transparent));
  content: "";
  pointer-events: none;
}

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

.live-pulse {
  animation: live-beacon 2.4s ease-out infinite;
}

.topbar-metric {
  position: relative;
  overflow: hidden;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.topbar-metric::after {
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  border-radius: 99px 99px 0 0;
  background: currentColor;
  content: "";
  opacity: 0.48;
  transform: scaleX(0.42);
  transform-origin: left;
  transition: transform var(--transition-smooth), opacity var(--transition-fast);
}

.topbar-metric:has(.metric-signal.violet) { color: #0d9a70; }
.topbar-metric:has(.metric-signal.blue) { color: #269fc6; }
.topbar-metric:has(.metric-signal.pink) { color: #d99419; }
.topbar-metric small,
.topbar-metric strong { color: var(--ink); }

.topbar-metric:hover {
  background: color-mix(in srgb, currentColor 7%, var(--surface-raised));
}

.topbar-metric:hover::after {
  opacity: 0.9;
  transform: scaleX(1);
}

.metric-signal {
  animation: signal-breathe 3.8s ease-in-out infinite;
  transform-origin: center bottom;
}

.topbar-metric:nth-child(2) .metric-signal { animation-delay: -1.2s; }
.topbar-metric:nth-child(3) .metric-signal { animation-delay: -2.4s; }

.connection-pill {
  position: relative;
  overflow: hidden;
}

.connection-pill::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -36%;
  width: 28%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  content: "";
  transform: skewX(-20deg);
  animation: status-shine 5.5s ease-in-out infinite;
}

.inbox-grid,
.dashboard-view,
.contacts-view,
.pipeline-view,
.automation-view,
.bot-view {
  position: relative;
  z-index: 1;
}

.lead-column,
.conversation-column,
.profile-panel,
.metric-card,
.dashboard-section,
.contacts-table-wrap,
.pipeline-column,
.automation-card,
.bot-tester {
  backdrop-filter: blur(16px);
}

.lead-card {
  animation: none;
}

.lead-card:nth-child(2) { animation-delay: 35ms; }
.lead-card:nth-child(3) { animation-delay: 70ms; }
.lead-card:nth-child(4) { animation-delay: 105ms; }
.lead-card:nth-child(5) { animation-delay: 140ms; }
.lead-card:nth-child(n + 6) { animation-delay: 175ms; }

.lead-card.active {
  background-size: 180% 100%;
  animation: none;
}

.unread-count {
  animation: none;
}

.metric-card::after {
  position: absolute;
  top: -30%;
  right: -15%;
  width: 7rem;
  height: 7rem;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  content: "";
  opacity: 0.7;
  transition: transform var(--transition-smooth), opacity var(--transition-smooth);
}

.metric-card:nth-child(2)::after { border-color: rgba(245, 158, 11, 0.25); }
.metric-card:nth-child(3)::after { border-color: rgba(56, 166, 232, 0.25); }
.metric-card:nth-child(4)::after { border-color: rgba(236, 72, 153, 0.25); }

.metric-card:hover::after {
  opacity: 1;
  transform: scale(1.18) rotate(22deg);
}

.dashboard-updated {
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--panel));
}

@keyframes ambient-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(0.96); }
  to { transform: translate3d(5%, 5%, 0) scale(1.08); }
}

@keyframes live-beacon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(65, 214, 160, 0.3); }
  60% { box-shadow: 0 0 0 7px rgba(65, 214, 160, 0); }
}

@keyframes signal-breathe {
  0%, 100% { opacity: 0.64; transform: scaleY(0.84); }
  50% { opacity: 1; transform: scaleY(1.08); }
}

@keyframes status-shine {
  0%, 56% { transform: translateX(0) skewX(-20deg); }
  76%, 100% { transform: translateX(520%) skewX(-20deg); }
}

@keyframes selection-glow {
  0%, 100% { box-shadow: inset 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
  50% { box-shadow: inset 14rem 0 3rem -5rem color-mix(in srgb, var(--accent) 20%, transparent); }
}

@keyframes count-pop {
  0%, 78%, 100% { transform: scale(1); }
  84% { transform: scale(1.12); }
  91% { transform: scale(0.96); }
}

@media (max-width: 760px) {
  .workspace::before {
    top: -16rem;
    right: -18rem;
  }

  .topbar::after {
    width: 55vw;
  }
}

/* El compositor tiene cuatro acciones; esta regla final evita que los temas
   visuales posteriores lo reduzcan a cuatro columnas y rompan el textarea. */
.composer {
  grid-template-columns: repeat(4, 36px) minmax(120px, 1fr) auto;
  align-items: center;
}

.composer > #internalNoteButton { grid-column: 1; }
.composer > #templateButton { grid-column: 2; }
.composer > #quickReplyButton { grid-column: 3; }
.composer > #attachmentButton { grid-column: 4; }
.composer > #messageInput { grid-column: 5; min-width: 0; }
.composer > .send-button { grid-column: 6; }
.composer > .attachment-preview { grid-column: 1 / -1; grid-row: 2; }

@media (max-width: 620px) {
  .composer {
    grid-template-columns: repeat(4, 34px) minmax(0, 1fr) 42px;
    gap: 6px;
    padding: 8px;
  }

  .composer > .send-button {
    min-width: 42px;
    padding: 0;
  }

  .composer > .send-button span { display: none; }
}

/* Mobile-first refinements for the operational workspace. */
@media (max-width: 760px) {
  body {
    overscroll-behavior: none;
  }

  .nav-rail {
    gap: 6px;
    scrollbar-width: none;
  }

  .nav-rail::-webkit-scrollbar { display: none; }
  .brand-lockup { flex: 0 0 auto; }
  .brand-mark { width: 36px; height: 36px; }
  .rail-button { flex: 0 0 42px; min-width: 42px; }
  .rail-button.bottom { margin-left: 0; }

  .topbar {
    min-height: 58px;
    padding: 8px 12px;
  }

  .topbar .eyebrow { display: none; }
  .topbar h1 { margin: 0; font-size: 18px; line-height: 1.15; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .icon-button { width: 36px; height: 36px; }

  .inbox-grid {
    grid-template-rows: minmax(142px, 30dvh) minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr) minmax(110px, .55fr);
    gap: 8px;
    padding: 10px;
  }

  .filters .search-box { grid-column: 1 / -1; height: 36px; }
  .segmented { height: 32px; }
  .conversation-filter { min-width: 0; height: 32px; }
  .lead-list { padding: 5px; }
  .lead-card { min-height: 68px; padding: 8px; }
  .lead-card footer { gap: 4px; }
  .lead-card footer span { font-size: 10px; }

  .conversation-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .lead-title h2 { font-size: 16px; }
  .lead-title p { font-size: 11px; }
  .conversation-actions { gap: 6px; }
  .conversation-actions select { min-height: 34px; font-size: 11px; }
  .conversation-actions .icon-button { width: 34px; height: 34px; }

  .message-timeline { padding: 12px; }
  .message { max-width: 88%; padding: 9px 11px; font-size: 13px; }

  .dashboard-view,
  .contacts-view,
  .pipeline-view,
  .automation-view,
  .bot-view { padding: 14px 12px; }

  .contacts-heading h2,
  .dashboard-heading h2 { font-size: 21px; }
  .contacts-heading-actions { width: 100%; flex-wrap: wrap; }
  .contacts-heading-actions > * { flex: 1 1 130px; }
  .contacts-table-wrap { margin-right: -12px; margin-left: -12px; border-radius: 0; }
  .contacts-table { min-width: 760px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 104px; padding: 12px; }
  .metric-card strong { font-size: 25px; }

  dialog.modal { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); padding: 16px; }
}

/* Muchos móviles informan un viewport CSS cercano a 900 px. En ese rango la
   bandeja debe seguir siendo vertical, no una versión recortada de escritorio. */
@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 58px minmax(0, 1fr);
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .nav-rail {
    position: static;
    z-index: 2;
    flex-direction: row;
    justify-content: flex-start;
    min-height: 58px;
    padding: 7px 8px;
    overflow: auto hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(139, 158, 193, .17);
  }

  .brand-copy,
  .workspace-switcher,
  .rail-section-label,
  .rail-label,
  .rail-badge,
  .rail-system-state { display: none; }

  .brand-lockup { flex: 0 0 auto; margin: 0 4px 0 0; padding: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .rail-button,
  .rail-button.bottom { flex: 0 0 42px; width: 42px; height: 42px; margin: 0; padding: 0; }

  .workspace { min-height: calc(100dvh - 58px); grid-template-rows: auto minmax(0, 1fr); overflow: visible; }
  .topbar { display: flex; align-items: center; flex-direction: row; min-height: 58px; padding: 8px 12px; }
  .topbar .eyebrow,
  .topbar-subtitle,
  .connection-pill,
  .topbar-metrics { display: none; }
  .topbar h1 { margin: 0; font-size: 18px; line-height: 1.15; }
  .topbar-actions { margin-left: auto; }

  .inbox-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    gap: 6px;
    padding: 6px;
  }

  .profile-panel { display: none; }
  .lead-column { max-height: 280px; }
  .conversation-column { min-height: 520px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(110px, .55fr); gap: 8px; padding: 10px; }
  .filters .search-box { grid-column: 1 / -1; height: 36px; }
  .segmented,
  .conversation-filter { height: 32px; min-width: 0; }
  .lead-list { padding: 5px; }
  .lead-card { min-height: 68px; padding: 8px; }

  .conversation-header { align-items: flex-start; flex-direction: column; min-height: 0; gap: 8px; padding: 10px 12px; }
  .lead-title { flex: 0 0 auto; width: 100%; }
  .conversation-actions { flex: 0 0 auto; width: 100%; gap: 6px; }
  .conversation-actions select { flex: 1 1 0; min-width: 0; min-height: 34px; font-size: 11px; }
  .conversation-actions .icon-button { width: 34px; height: 34px; }
  .message-timeline { min-height: 280px; padding: 12px; }

  /* Acciones arriba y redacción debajo: no dependemos del ancho que el
     navegador declare para el móvil y cada control conserva su espacio. */
  .composer {
    grid-template-columns: repeat(4, 42px);
    grid-template-rows: 42px minmax(44px, auto);
    align-items: center;
    gap: 7px;
    padding: 9px;
  }

  .composer > #internalNoteButton { grid-column: 1; grid-row: 1; }
  .composer > #templateButton { grid-column: 2; grid-row: 1; }
  .composer > #quickReplyButton { grid-column: 3; grid-row: 1; }
  .composer > #attachmentButton { grid-column: 4; grid-row: 1; }
  .composer > #messageInput { grid-column: 1 / 4; grid-row: 2; min-height: 44px; max-height: 96px; }
  .composer > .send-button { grid-column: 4; grid-row: 2; min-width: 42px; min-height: 44px; padding: 0; }
  .composer > .send-button span { display: none; }
  .composer > .attachment-preview { grid-row: 3; }
}

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

/* El ancho útil depende de las columnas laterales; este ajuste usa el tamaño
   real de la conversación en vez del ancho total de la ventana. */
.conversation-column { container-type: inline-size; }

@container (max-width: 830px) {
  .conversation-header {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
    min-height: 64px;
    gap: 8px;
  }

  .lead-title { flex: 1 1 150px; width: auto; }
  .lead-title p { display: none; }

  .conversation-actions {
    display: flex;
    flex: 0 0 auto;
    width: auto;
    gap: 5px;
  }

  .conversation-actions select {
    width: auto;
    min-width: 0;
    max-width: none;
    height: 32px;
    min-height: 32px;
    padding: 0 6px;
    font-size: 10px;
  }

  .conversation-actions .icon-button {
    width: 32px;
    height: 32px;
  }

  #outboundChannelSelect { width: 78px; }
  #assigneeSelect { width: 104px; }
  #stageSelect { width: 78px; }
}

@container (max-width: 540px) {
  .lead-title { flex-basis: 118px; }
  #outboundChannelSelect { width: 70px; }
  #assigneeSelect { width: 90px; }
  #stageSelect { width: 70px; }
  .conversation-actions { gap: 4px; }
  .conversation-actions .icon-button { width: 30px; height: 30px; }
}

/* Inbox de móvil: lista de chats o conversación, como WhatsApp. */
@media (max-width: 1000px) {
  .inbox-grid {
    display: block;
    padding: 0;
    background: var(--page);
  }

  .inbox-grid:not(.mobile-chat-open) .conversation-column,
  .inbox-grid.mobile-chat-open .lead-column { display: none; }

  .inbox-grid:not(.mobile-chat-open) .lead-column {
    display: grid;
    max-height: none;
    height: calc(100dvh - 116px);
    border: 0;
    border-radius: 0;
  }

  .inbox-grid.mobile-chat-open .conversation-column {
    display: grid;
    height: calc(100dvh - 116px);
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  .filters { padding: 12px; background: var(--panel); }
  .lead-list { padding: 8px; }
  .lead-card { min-height: 74px; border-radius: 10px; }

  .conversation-header {
    flex-direction: row;
    align-items: center;
    min-height: 62px;
    padding: 9px 12px;
  }

  .lead-title {
    grid-template-columns: 36px 38px minmax(0, 1fr);
    flex: 1 1 auto;
    align-items: center;
  }

  .mobile-inbox-back { display: inline-grid; width: 36px; height: 36px; place-items: center; }
  .conversation-actions { width: auto; flex: 0 0 auto; }
  .conversation-actions select { display: none; }
  .conversation-actions .icon-button { width: 36px; height: 36px; }
  .message-timeline { min-height: 0; padding: 14px 12px; }

  .composer {
    grid-template-columns: 42px minmax(0, 1fr) 46px;
    grid-template-rows: minmax(46px, auto);
    gap: 7px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--panel);
  }

  .composer > #internalNoteButton,
  .composer > #templateButton,
  .composer > #quickReplyButton { display: none; }
  .composer > #attachmentButton { grid-column: 1; grid-row: 1; width: 42px; height: 42px; }
  .composer > #messageInput { grid-column: 2; grid-row: 1; min-height: 46px; max-height: 96px; border-radius: 22px; }
  .composer > .send-button { grid-column: 3; grid-row: 1; width: 46px; min-width: 46px; min-height: 46px; border-radius: 50%; }
  .composer > .attachment-preview { grid-column: 1 / -1; grid-row: 2; }

  /* Al abrir una conversación en iPhone, el chat es la pantalla completa. */
  .app-shell.mobile-chat-open {
    display: block;
    min-height: 100dvh;
  }

  .app-shell.mobile-chat-open .nav-rail,
  .app-shell.mobile-chat-open .topbar { display: none; }

  .app-shell.mobile-chat-open .workspace {
    display: block;
    min-height: 100dvh;
  }

  .app-shell.mobile-chat-open .inbox-grid,
  .app-shell.mobile-chat-open .conversation-column {
    height: 100dvh;
  }

  .app-shell.mobile-chat-open .conversation-column {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
}

/* Mantiene el lienzo por encima de los estilos generales de vistas. */
.automation-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #eef0f4;
}

:root[data-theme="dark"] .automation-view { background: #111317; }

@media (max-width: 920px) {
  .automation-view { padding: 0; overflow: auto; }
}

/* Formularios, CRM e IA omnicanal */
.forms-view {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  background: var(--page);
}

.forms-heading-actions,
.section-heading-inline,
.form-card-actions,
.form-fields-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.forms-heading-actions { flex-wrap: wrap; }

.forms-layout {
  display: grid;
  grid-template-columns: minmax(300px, .72fr) minmax(440px, 1.28fr);
  gap: 18px;
  max-width: 1240px;
  margin: 22px auto 0;
}

.forms-catalog,
.form-submissions,
.ai-explain-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
}

.section-heading-inline {
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-heading-inline h3 { margin: 2px 0 0; font-size: 17px; }
.section-heading-inline > span {
  display: grid;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.forms-list,
.submissions-list,
.crm-activity-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.forms-list,
.submissions-list { max-height: calc(100dvh - 260px); overflow: auto; }

.form-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-card-main {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 13px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.form-card-main small { color: var(--muted); }
.form-status {
  width: max-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.form-status.is-live { background: var(--accent-soft); color: var(--accent-strong); }
.form-status.is-blocked { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }

.form-card-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.form-card-actions button {
  min-height: 30px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}
.form-card-actions button:hover { background: var(--accent-soft); }
.form-card-actions .is-danger { color: var(--rose); }

.submission-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}
.submission-card header { display: flex; justify-content: space-between; gap: 12px; }
.submission-card time,
.submission-card dt { color: var(--muted); font-size: 11px; }
.submission-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 12px 0; }
.submission-card dl div { min-width: 0; }
.submission-card dt { font-weight: 800; text-transform: uppercase; }
.submission-card dd { overflow-wrap: anywhere; margin: 2px 0 0; font-size: 13px; }

.form-editor-dialog { width: min(900px, calc(100vw - 28px)); }
.form-fields-heading { align-items: flex-end; margin: 18px 0 10px; }
.field-type-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.field-type-buttons button {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}
.form-fields-editor { display: grid; gap: 9px; max-height: 360px; overflow: auto; padding: 2px; }
.form-field-row {
  display: grid;
  grid-template-columns: 28px minmax(130px, 1.2fr) minmax(110px, .8fr) 120px minmax(120px, 1fr) auto 36px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-muted);
}
.form-field-row label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.form-field-order { display: grid; width: 24px; height: 24px; place-items: center; align-self: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 800; }
.form-field-options { grid-column: 2 / 6; }
.form-field-required { display: flex !important; align-items: center; align-self: center; white-space: nowrap; }

.follow-up-form { display: grid; gap: 8px; margin: 10px 0 14px; }
.follow-up-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.crm-activity-list { max-height: 280px; overflow: auto; }
.crm-activity { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.crm-activity-icon { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }
.crm-activity p { margin: 3px 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.crm-activity small,
.crm-activity time { display: block; color: var(--muted); font-size: 10px; }

.pipeline-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; cursor: grab; }
.pipeline-card:active { cursor: grabbing; }
.pipeline-card-main { display: grid; min-width: 0; gap: 4px; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; }
.pipeline-stage-control select { width: 36px; min-height: 32px; padding: 0; color: transparent; cursor: pointer; }
.pipeline-column.is-drop-target { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 52%, var(--panel)); box-shadow: inset 0 0 0 2px var(--focus-ring); }
.pipeline-card.is-dragging { opacity: .45; transform: rotate(1.5deg) scale(.98); }
.pipeline-card.is-updating { cursor: wait; opacity: .72; }
.pipeline-card.is-updating::after { content: ""; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: pipeline-saving 700ms linear infinite; }
.pipeline-card.is-updating .pipeline-stage-control { display: none; }

@keyframes pipeline-saving { to { transform: rotate(360deg); } }

.bot-view {
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, .72fr);
  grid-template-rows: auto minmax(0, 1fr);
}
.bot-heading { grid-column: 1 / -1; }
.bot-tester { width: 100%; }
.ai-explain-panel { display: grid; align-content: start; gap: 16px; }
.ai-explain-panel h3,
.ai-explain-panel h4 { margin: 0; }
.ai-explain-panel h4 { margin-bottom: 7px; font-size: 12px; }
.ai-analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.ai-analysis-grid div { padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.ai-analysis-grid dt { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.ai-analysis-grid dd { overflow-wrap: anywhere; margin: 3px 0 0; font-size: 12px; font-weight: 800; }
.ai-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { padding: 5px 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-strong); font-size: 10px; }
.ai-chip.muted { background: var(--surface-muted); color: var(--muted); }
.ai-chip.warning { background: color-mix(in srgb, var(--amber) 16%, var(--panel)); color: var(--amber); }
.ai-fallback { padding: 12px; border-radius: 9px; background: color-mix(in srgb, var(--steel) 10%, var(--panel)); }
.ai-fallback p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.workflow-mini-icon.stage { background: #e5edf7; color: #355f8c; }
.workflow-mini-icon.activity { background: #e5f3e9; color: #247246; }
.workflow-mini-icon.stop { background: #fbe7ed; color: #bc2557; }
.workflow-stop-bot-note { display: block; padding: 9px 10px; border: 1px solid color-mix(in srgb, #bc2557 28%, var(--line)); border-radius: 8px; background: color-mix(in srgb, #bc2557 7%, var(--panel)); color: var(--muted); font-size: 11px; line-height: 1.45; }
.workflow-test-dialog { width: min(700px, calc(100vw - 28px)); }
.workflow-test-result { margin: 14px 0; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); }
.workflow-test-result p { margin: 6px 0; color: var(--muted); }
.workflow-test-result ul { max-height: 140px; overflow: auto; margin: 8px 0; padding-left: 20px; font-size: 12px; }
.workflow-test-result small { color: var(--accent-strong); font-weight: 700; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; }

/* Superficies públicas: formulario y webchat */
.public-page {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34%),
    radial-gradient(circle at 88% 92%, color-mix(in srgb, var(--amber) 13%, transparent), transparent 32%),
    var(--page);
}

.public-shell {
  display: grid;
  width: min(680px, 100%);
  min-height: 100dvh;
  align-content: center;
  gap: 16px;
  margin: 0 auto;
  padding: 28px 18px;
}

.public-brand {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.public-brand span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 800;
}

.public-brand strong { font-family: 'Manrope', sans-serif; font-size: 18px; letter-spacing: .04em; }

.public-card {
  overflow: hidden;
  padding: 28px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, var(--accent));
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: 0 28px 80px rgba(10, 40, 31, .13);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.public-card-heading { margin-bottom: 22px; }
.public-card-heading h1,
.public-unavailable h1,
.public-success h1 { margin: 3px 0 8px; font-family: 'Manrope', sans-serif; font-size: clamp(26px, 5vw, 38px); line-height: 1.08; }
.public-card-heading > p:last-child,
.public-unavailable > p,
.public-success p { margin: 0; color: var(--muted); line-height: 1.6; }

.public-fields { display: grid; gap: 14px; }
.public-preview { margin-bottom: 22px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--accent-soft); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.public-preview p { margin: 6px 0; color: var(--muted); }
.public-preview a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-strong); font-weight: 700; }
.public-field { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 800; }
.public-field small { color: var(--muted); font-size: 10px; font-weight: 600; }
.public-field input,
.public-field select,
.public-field textarea,
.webchat-composer textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input);
  color: var(--ink);
  font: inherit;
  outline: none;
}
.public-field textarea { resize: vertical; }
.public-field input:focus,
.public-field select:focus,
.public-field textarea:focus,
.webchat-composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.public-field input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--accent); }

.public-consent {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.public-consent input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.public-feedback { margin: 10px 0; padding: 10px; border-radius: 8px; background: color-mix(in srgb, var(--rose) 12%, var(--panel)); color: var(--rose); font-size: 12px; font-weight: 700; }
.public-footer { color: var(--muted); font-size: 10px; text-align: center; }

.public-loading,
.public-unavailable,
.public-success { display: grid; min-height: 280px; place-items: center; align-content: center; gap: 12px; text-align: center; }
.public-spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: public-spin .8s linear infinite; }
.public-success > span { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-size: 28px; font-weight: 800; }

.webchat-shell { width: min(760px, 100%); }
.webchat-card { display: grid; grid-template-rows: auto minmax(280px, 1fr) auto auto; height: min(700px, calc(100dvh - 140px)); min-height: 520px; padding: 0; }
.webchat-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 11px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.webchat-avatar { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: var(--accent); color: white; font-weight: 800; }
.webchat-header h1 { margin: 0; font-size: 15px; }
.webchat-header p { display: flex; align-items: center; gap: 6px; margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.webchat-header i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.webchat-header i.connected { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.webchat-messages {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: auto;
  margin: 0;
  padding: 18px;
  background: color-mix(in srgb, var(--page) 70%, var(--panel));
  list-style: none;
}
.webchat-message { display: grid; max-width: 82%; gap: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px 12px 12px 3px; background: var(--panel); }
.webchat-message.visitor { align-self: flex-end; border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); border-radius: 12px 12px 3px; background: var(--message-out); }
.webchat-message p { overflow-wrap: anywhere; margin: 0; font-size: 13px; line-height: 1.5; }
.webchat-message span { color: var(--muted); font-size: 9px; }
.webchat-workflow-buttons { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.webchat-workflow-buttons button { min-height: 32px; padding: 6px 10px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); cursor: pointer; font: inherit; font-size: 11px; font-weight: 800; }
.webchat-workflow-buttons button:hover:not(:disabled) { background: var(--accent); color: white; }
.webchat-workflow-buttons button:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.webchat-workflow-buttons button:disabled { cursor: wait; opacity: .65; }
.webchat-empty { display: grid; min-height: 100%; place-items: center; align-content: center; gap: 5px; color: var(--muted); text-align: center; }
.webchat-feedback { margin: 0; border-radius: 0; }
.webchat-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; padding: 12px; border-top: 1px solid var(--line); background: var(--panel); }
.webchat-composer textarea { min-height: 44px; max-height: 120px; resize: none; }
.webchat-composer .send-button { min-height: 44px; }

@keyframes public-spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .forms-layout { grid-template-columns: 1fr; }
  .forms-list,
  .submissions-list { max-height: none; }
  .bot-view { grid-template-columns: 1fr; }
  .bot-heading { grid-column: auto; }
  .ai-explain-panel { grid-row: 3; }
  .form-field-row { grid-template-columns: 26px repeat(2, minmax(120px, 1fr)) 36px; }
  .form-field-row > label:nth-of-type(3),
  .form-field-row > label:nth-of-type(4) { grid-row: 2; }
  .form-field-options { grid-column: 2 / 4; }
}

@media (max-width: 760px) {
  .forms-view,
  .bot-view { padding: 16px; }
  .forms-heading-actions { width: 100%; justify-content: stretch; }
  .forms-heading-actions button { flex: 1 1 auto; }
  .forms-catalog,
  .form-submissions,
  .ai-explain-panel { padding: 14px; }
  .submission-card dl,
  .ai-analysis-grid { grid-template-columns: 1fr; }
  .form-fields-heading { align-items: stretch; flex-direction: column; }
  .field-type-buttons { justify-content: flex-start; }
  .form-field-row { grid-template-columns: 24px minmax(0, 1fr) 36px; align-items: center; }
  .form-field-row label,
  .form-field-options { grid-column: 2; }
  .form-field-row > .icon-button { grid-column: 3; grid-row: 1; }
  .form-field-required { grid-column: 2 / 4 !important; }
  .bot-test-composer { grid-template-columns: 1fr; }
  .public-shell { align-content: start; padding: 18px 12px; }
  .public-card { padding: 20px; border-radius: 14px; }
  .webchat-card { height: calc(100dvh - 116px); min-height: 480px; padding: 0; }
}

@media (max-width: 600px) {
  .public-page.webchat-page { overflow: hidden; }
  .webchat-page .public-shell { width: 100%; height: 100dvh; gap: 8px; padding: 8px 0 0; }
  .webchat-page .public-brand,
  .webchat-page .public-footer { margin-inline: 12px; }
  .webchat-card { height: calc(100dvh - 92px); border-right: 0; border-left: 0; border-radius: 0; }
  .webchat-message { max-width: 90%; }
  .webchat-composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .public-form-card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .public-spinner,
  .chart-bar,
  .stage-row i,
  .modal[open],
  .modal[open]::backdrop { animation: none !important; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Capa final de operación: densidad estable, foco visible y lectura rápida. */
:root {
  --control-focus: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --control-focus-strong: 0 0 0 3px color-mix(in srgb, var(--accent) 38%, transparent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="tab"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--control-focus-strong);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.search-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  box-shadow: var(--control-focus);
}

.conversation-header { isolation: isolate; }

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

.conversation-actions { flex-wrap: nowrap; }

.conversation-actions select {
  min-width: 0;
  text-overflow: ellipsis;
}

.message-timeline {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.message { line-height: 1.45; }

.message span { font-variant-numeric: tabular-nums; }

.composer {
  position: relative;
  transition: box-shadow var(--transition-fast), background var(--transition-fast);
}

.composer:focus-within {
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--accent) 72%, transparent);
}

.composer.is-sending {
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--accent) 72%, transparent);
}

.composer.is-sending::after {
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  height: 2px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  content: "";
  pointer-events: none;
  transform: scaleX(.28);
  transform-origin: left;
  animation: sole-composer-progress 900ms cubic-bezier(.16, 1, .3, 1) infinite;
}

.composer textarea::placeholder,
.search-box input::placeholder {
  color: color-mix(in srgb, var(--muted) 88%, var(--panel));
  opacity: 1;
}

@container (max-width: 760px) {
  .conversation-header {
    gap: 6px;
    padding-inline: 10px;
  }

  .lead-title { flex-basis: 124px; }
  .conversation-actions { gap: 4px; }
  #outboundChannelSelect { width: 72px; }
  #assigneeSelect { width: 94px; }
  #stageSelect { width: 72px; }
}

@media (min-width: 1001px) and (max-width: 1320px) {
  .inbox-grid {
    grid-template-columns: minmax(230px, .92fr) minmax(0, 2fr) minmax(220px, .86fr);
  }

  .conversation-header {
    gap: 10px;
    padding-inline: 12px;
  }
}
@media (min-width: 1001px) {
  .inbox-grid.is-profile-collapsed {
    grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  }
}

/* Movimiento operativo: continuidad entre vistas y feedback de estado. */
@supports (view-transition-name: none) {
  :root[data-theme-transition]::view-transition-old(root) {
    animation: sole-theme-fade 180ms cubic-bezier(.4, 0, 1, 1) both;
  }

  :root[data-theme-transition]::view-transition-new(root) {
    animation: sole-theme-reveal 440ms cubic-bezier(.16, 1, .3, 1) both;
    clip-path: circle(0 at var(--theme-reveal-x) var(--theme-reveal-y));
  }
}

.conversation-column.is-loading .message-timeline {
  opacity: .68;
  pointer-events: none;
}

.conversation-column.is-loading #leadAvatar {
  animation: sole-context-pulse 1s ease-in-out infinite;
}

.lead-card.active.is-just-selected {
  animation: sole-selection-settle 320ms cubic-bezier(.16, 1, .3, 1) both;
}

.message.is-new,
.webchat-message.is-new {
  animation: sole-message-arrive 240ms cubic-bezier(.16, 1, .3, 1) both;
}

.conversation-reply-badge.is-updated {
  animation: sole-count-update 360ms cubic-bezier(.16, 1, .3, 1) both;
}

.topbar-metric.is-updated strong {
  display: inline-block;
  animation: sole-metric-update 300ms cubic-bezier(.16, 1, .3, 1) both;
}

.webchat-composer {
  transition: box-shadow var(--transition-fast), background var(--transition-fast);
}

.webchat-composer:focus-within,
.webchat-composer.is-sending {
  box-shadow: inset 0 2px 0 color-mix(in srgb, var(--accent) 72%, transparent);
}

.webchat-composer.is-sending .send-button { cursor: wait; }

@keyframes sole-theme-fade {
  to { opacity: 0; }
}

@keyframes sole-theme-reveal {
  to { clip-path: circle(150vmax at var(--theme-reveal-x) var(--theme-reveal-y)); }
}
@keyframes sole-context-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); }
}

@keyframes sole-selection-settle {
  from { box-shadow: inset 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
  45% { box-shadow: inset 13rem 0 3rem -5rem color-mix(in srgb, var(--accent) 18%, transparent); }
  to { box-shadow: none; }
}

@keyframes sole-message-arrive {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sole-count-update {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.16); }
  72% { transform: scale(.96); }
}

@keyframes sole-metric-update {
  0% { opacity: .58; transform: translateY(4px) scale(.96); }
  58% { opacity: 1; transform: translateY(0) scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes sole-composer-progress {
  from { opacity: .45; transform: scaleX(.28); }
  50% { opacity: 1; transform: scaleX(1); }
  to { opacity: .45; transform: scaleX(.28); }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root),
  .conversation-column.is-loading #leadAvatar,
  .lead-card.active.is-just-selected,
  .message.is-new,
  .webchat-message.is-new,
  .conversation-reply-badge.is-updated { animation: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-metric.is-updated strong,
  .composer.is-sending::after { animation: none !important; }
}

.bot-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.assistant-config-fields {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.assistant-config-fields label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.assistant-config-fields input,
.assistant-config-fields textarea {
  width: 100%;
}

.assistant-config-fields textarea {
  resize: vertical;
}

@media (max-width: 640px) {
  .bot-heading-actions { width: 100%; justify-content: space-between; }
}

/* Settings: a quiet, grouped workspace with native system typography. */
#settingsDialog {
  --settings-bg: var(--page);
  --settings-sidebar: var(--nav);
  --settings-card: var(--panel);
  --settings-text: var(--ink);
  --settings-muted: var(--muted);
  --settings-line: var(--line);
  --settings-control: var(--input);
  --settings-accent: var(--accent);
  --settings-accent-soft: var(--accent-soft);
  --settings-radius: var(--radius-card);
  width: min(980px, calc(100vw - 48px));
  height: min(740px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--settings-line);
  border-radius: 22px;
  background: var(--settings-bg);
  color: var(--settings-text);
  box-shadow: 0 32px 100px rgb(0 0 0 / 22%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  color-scheme: light;
}

.history-action {
  align-self: center;
  flex-shrink: 0;
  max-width: 100%;
  min-height: 44px;
  font-size: 12px;
}

:root[data-theme="dark"] #settingsDialog { color-scheme: dark; }

#settingsDialog[open] {
  display: flex;
  flex-direction: column;
}

#settingsDialog .settings-window-header {
  flex: 0 0 auto;
  min-height: 86px;
  margin: 0;
  padding: 20px 26px;
  border-bottom: 1px solid var(--settings-line);
  background: var(--settings-card);
  gap: 20px;
}

#settingsDialog h2 { font-size: 20px; font-weight: 650; letter-spacing: -.5px; }
#settingsDialog .settings-window-header p { margin: 4px 0 0; color: var(--settings-muted); font-size: 13px; line-height: 1.45; }
#settingsDialog .settings-close { width: 34px; height: 34px; flex: 0 0 34px; border: 0; border-radius: 50%; background: var(--settings-control); color: var(--settings-muted); box-shadow: none; }
#settingsDialog .settings-close svg { width: 16px; height: 16px; }

.settings-layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); flex: 1; min-height: 0; }
.settings-sidebar { padding: 24px 12px; border-right: 1px solid var(--settings-line); background: var(--settings-sidebar); overflow-y: auto; }
.settings-sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 26px; }
.settings-sidebar-brand > span { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: #117a5b; color: #fff; font-size: 22px; font-weight: 600; }
.settings-sidebar-brand strong { display: block; font-size: 13px; letter-spacing: .5px; }
.settings-sidebar-brand small { display: block; margin-top: 3px; color: var(--settings-muted); font-size: 11px; }
.settings-navigation { display: grid; gap: 5px; }
#settingsDialog .settings-nav-item { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 44px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--settings-text); text-align: left; font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.3; transition: background 140ms ease, color 140ms ease; }
#settingsDialog .settings-nav-item:hover { background: color-mix(in srgb, var(--settings-text) 5%, transparent); }
#settingsDialog .settings-nav-item[aria-selected="true"] { background: var(--settings-accent-soft); color: var(--settings-accent); font-weight: 600; }
.settings-nav-icon { display: grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; border-radius: 7px; color: #fff; }
.settings-nav-icon.general { background: #74747b; }
.settings-nav-icon.whatsapp { background: #208642; }
.settings-nav-icon.assistant { background: #7860bf; }
.settings-nav-icon.team { background: #2875c8; }
.settings-nav-icon.billing { background: #b36a26; }
.settings-nav-icon.account { background: #74747b; }
.settings-nav-icon svg, .settings-account-avatar svg, .settings-action-list svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.settings-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.settings-scroll { flex: 1; min-height: 0; padding: 32px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.settings-pane { outline-offset: 4px; }
.settings-pane-heading { margin-bottom: 24px; }
.settings-pane-heading h3 { margin: 0; font-size: 25px; font-weight: 650; letter-spacing: -.8px; line-height: 1.2; }
.settings-pane-heading p { margin: 8px 0 0; color: var(--settings-muted); font-size: 14px; line-height: 1.5; }
#settingsDialog .settings-card { margin: 0 0 16px; padding: 0; overflow: hidden; border: 1px solid var(--settings-line); border-radius: var(--settings-radius); background: var(--settings-card); box-shadow: 0 1px 2px rgb(0 0 0 / 2%); }
#settingsDialog .settings-card h4 { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.5; }
#settingsDialog .settings-card p { margin: 5px 0 0; color: var(--settings-muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.settings-preference-row { display: grid; grid-template-columns: minmax(0, 1fr) 175px; gap: 22px; align-items: center; padding: 20px; }
.settings-preference-row + .settings-preference-row { border-top: 1px solid var(--settings-line); }
.settings-preference-row label { font-size: 14px; font-weight: 600; }
#settingsDialog .settings-preference-row p { margin-top: 6px; font-size: 12px; line-height: 1.5; }
#settingsDialog input:not([type=checkbox]), #settingsDialog select, #settingsDialog textarea { width: 100%; min-width: 0; min-height: 42px; padding: 10px 12px; border: 1px solid var(--settings-line); border-radius: 8px; background: var(--settings-control); color: var(--settings-text); font-family: inherit; font-size: 13px; font-weight: 400; line-height: 1.45; box-shadow: none; }
#settingsDialog textarea { resize: vertical; }
#settingsDialog input::placeholder, #settingsDialog textarea::placeholder { color: var(--settings-muted); opacity: .8; }
#settingsDialog :is(input, select, textarea):focus { border-color: var(--settings-accent); outline: 3px solid color-mix(in srgb, var(--settings-accent) 22%, transparent); outline-offset: 1px; box-shadow: none; }
#settingsDialog :is(button, summary, [role=tabpanel]):focus-visible { outline: 3px solid var(--settings-accent); outline-offset: 3px; box-shadow: none; }
#settingsDialog .settings-card-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 20px; border-bottom: 1px solid var(--settings-line); }
#settingsDialog .settings-fields { padding: 20px; gap: 18px; }
#settingsDialog .settings-fields label { display: grid; gap: 8px; color: var(--settings-text); font-size: 13px; font-weight: 600; }
#settingsDialog .assistant-config-fields { margin-top: 0; }
#settingsDialog .settings-footnote { margin: -4px 4px 22px; color: var(--settings-muted); font-size: 12px; line-height: 1.7; }
#settingsDialog .settings-details summary { padding: 17px 20px; cursor: pointer; color: var(--settings-muted); font-size: 13px; font-weight: 500; }
#settingsDialog .settings-details[open] summary { border-bottom: 1px solid var(--settings-line); color: var(--settings-text); }
#settingsDialog .settings-details > div, #settingsDialog .settings-details > p { margin: 0; padding: 18px 20px; }
#settingsDialog .settings-details label { color: var(--settings-muted); font-size: 12px; }
#settingsDialog .settings-details code { display: block; margin-top: 10px; overflow-wrap: anywhere; color: var(--settings-text); font-size: 12px; line-height: 1.7; }
#settingsDialog .settings-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 20px; cursor: pointer; }
.settings-switch-row strong { display: block; font-size: 14px; font-weight: 600; }
.settings-switch-row small { display: block; margin-top: 6px; color: var(--settings-muted); font-size: 12px; line-height: 1.5; }
#settingsDialog .settings-switch-row input { appearance: none; width: 44px; height: 26px; flex: 0 0 44px; margin: 0; padding: 2px; border: 0; border-radius: 16px; background: #9b9ba2; cursor: pointer; transition: background 160ms ease; }
#settingsDialog .settings-switch-row input::before { content: ""; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 20%); transition: transform 160ms ease; }
#settingsDialog .settings-switch-row input:checked { background: #248844; }
#settingsDialog .settings-switch-row input:checked::before { transform: translateX(18px); }
.settings-card-body { padding: 20px; }
#settingsDialog .settings-small-label { display: block; margin-bottom: 5px; color: var(--settings-muted); font-size: 12px; }
#settingsDialog #billingPlanStatus { font-size: 20px; letter-spacing: -.4px; }
.billing-period { display: flex; flex-wrap: wrap; gap: 12px 18px; margin: 22px 0; padding: 14px 16px; border: 1px solid var(--settings-line); border-radius: var(--settings-radius); }
.billing-period legend { color: var(--settings-muted); font-size: 12px; padding: 0 5px; }
.billing-period label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; cursor: pointer; }
#settingsDialog .billing-period input[type=radio] { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--settings-accent); }
.billing-consumption { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 0 0 22px; }
.billing-meter > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 5px; font-size: 12px; margin-bottom: 8px; }
.billing-meter span { color: var(--settings-muted); }
.billing-meter progress { display: block; width: 100%; height: 6px; accent-color: var(--settings-accent); }
.billing-notice { padding: 14px 16px; margin: 0 0 20px; color: var(--settings-text); background: var(--settings-accent-soft); border-radius: var(--settings-radius); font-size: 13px; line-height: 1.6; }
.billing-plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.billing-plan { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 18px 14px; border: 1px solid var(--settings-line); border-radius: var(--settings-radius); background: var(--settings-card); }
.billing-plan-featured { border-color: var(--settings-accent); box-shadow: inset 0 3px 0 var(--settings-accent); }
.billing-plan-heading { min-height: 44px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
#settingsDialog .billing-plan h4 { font-size: 15px; margin: 0; }
.billing-badge { display: inline-block; padding: 3px 7px; color: var(--settings-accent); background: var(--settings-accent-soft); border-radius: 5px; font-size: 10px; font-weight: 650; }
#settingsDialog .billing-price { margin: 0; font-size: clamp(22px, 2.5vw, 30px); font-weight: 650; letter-spacing: -.6px; color: var(--settings-text); }
.billing-price span { margin-left: 3px; font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--settings-muted); }
#settingsDialog .billing-price-note { margin: 0; color: var(--settings-muted); font-size: 11px; line-height: 1.5; }
.billing-plan ul { display: grid; gap: 10px; margin: 0 0 6px; padding-left: 17px; color: var(--settings-text); font-size: 12px; line-height: 1.5; }
#settingsDialog .billing-plan button { width: 100%; min-height: 44px; margin-top: auto; }
#settingsDialog .billing-plan-featured button:not(:disabled) { color: var(--settings-card); background: var(--settings-accent); }
#settingsDialog .billing-plan button:disabled { cursor: default; }
@media (max-width: 1000px) { .billing-plans { grid-template-columns: 1fr; } .billing-plan-heading { min-height: 0; justify-content: space-between; } }
@media (max-width: 420px) { .billing-consumption { grid-template-columns: 1fr; gap: 16px; } }
#settingsDialog .invite-form { grid-template-columns: minmax(0, 1fr) 125px auto; margin: 0 0 18px; }
#settingsDialog .owner-list { gap: 10px; }
#settingsDialog .owner-row { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 10px; align-items: center; }
#settingsDialog .owner-row .icon-button { width: 36px; height: 36px; border: 0; color: var(--settings-muted); background: transparent; }
#settingsDialog .member-row { padding: 14px; background: var(--settings-control); }
#settingsDialog .member-controls select { width: auto; }
#settingsDialog .connection-result { margin: 0 20px 20px; padding: 12px; border-radius: 8px; overflow-wrap: anywhere; color: var(--settings-accent); background: var(--settings-accent-soft); font-size: 13px; }
#settingsDialog .connection-result.error { color: #e74750; background: color-mix(in srgb, #e74750 10%, var(--settings-card)); }
#settingsDialog .settings-card-body .connection-result { margin: 0 0 18px; }
#settingsDialog .secondary-button { min-height: 38px; padding: 8px 14px; border: 1px solid var(--settings-line); border-radius: 8px; background: var(--settings-control); color: var(--settings-accent); box-shadow: none; font-size: 12px; font-weight: 600; line-height: 1.4; }
#settingsDialog .secondary-button:hover { background: var(--settings-accent-soft); transform: none; }
#settingsDialog button:disabled { opacity: .5; cursor: wait; }
.settings-account-row { display: flex; gap: 15px; align-items: center; padding: 24px 20px; }
.settings-account-avatar { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; background: var(--settings-control); color: var(--settings-muted); }
.settings-account-avatar svg { width: 25px; height: 25px; }
.settings-account-row > div { min-width: 0; }
.settings-account-row strong { overflow-wrap: anywhere; font-size: 16px; font-weight: 600; }
#settingsDialog .settings-action-list button { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; padding: 20px; border: 0; border-radius: 0; background: transparent; color: var(--settings-text); text-align: left; }
#settingsDialog .settings-action-list button + button { border-top: 1px solid var(--settings-line); }
#settingsDialog .settings-action-list button:hover { background: var(--settings-control); }
.settings-action-list strong { display: block; font-size: 14px; font-weight: 600; }
.settings-action-list small { display: block; margin-top: 6px; color: var(--settings-muted); font-size: 12px; line-height: 1.5; }
.settings-action-list svg { width: 21px; height: 21px; flex: 0 0 21px; color: var(--settings-muted); }
#settingsDialog .settings-action-list .logout-button strong, #settingsDialog .settings-action-list .logout-button svg { color: #e74750; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 20px; padding: 18px 28px; border-top: 1px solid var(--settings-line); background: var(--settings-card); }
.settings-footer p { margin: 0; color: var(--settings-muted); font-size: 12px; line-height: 1.5; }
#settingsDialog .settings-footer .send-button { min-height: 42px; padding: 10px 18px; border: 0; border-radius: 9px; background: #0066cc; color: #fff; box-shadow: none; font-size: 13px; font-weight: 600; line-height: 1.4; }
#settingsDialog .settings-footer .send-button:hover:not(:disabled) { background: #0056ad; transform: none; }

@media (max-width: 720px) {
  #settingsDialog { width: calc(100vw - 20px); height: calc(100dvh - 20px); max-height: calc(100dvh - 20px); border-radius: 18px; }
  #settingsDialog .settings-window-header { min-height: 74px; padding: 16px 18px; gap: 12px; }
  #settingsDialog h2 { font-size: 18px; }
  #settingsDialog .settings-window-header p { font-size: 12px; }
  #settingsDialog .settings-close { width: 44px; height: 44px; flex-basis: 44px; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-sidebar { padding: 10px; border-right: 0; border-bottom: 1px solid var(--settings-line); overflow: visible; }
  .settings-sidebar-brand { display: none; }
  .settings-navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  #settingsDialog .settings-nav-item { justify-content: center; gap: 6px; min-height: 46px; padding: 8px 5px; font-size: 11px; text-align: center; }
  .settings-nav-icon { width: 22px; height: 22px; flex-basis: 22px; border-radius: 6px; }
  .settings-nav-icon svg { width: 15px; height: 15px; }
  .settings-scroll { padding: 24px 18px; }
  .settings-pane-heading h3 { font-size: 23px; }
  .settings-pane-heading p { font-size: 13px; }
  .settings-preference-row { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 18px; }
  #settingsDialog .settings-fields, .settings-card-body, #settingsDialog .settings-card-heading { padding: 18px; }
  #settingsDialog .settings-fields { grid-template-columns: minmax(0, 1fr); }
  #settingsDialog .settings-switch-row { padding: 18px; gap: 15px; }
  #settingsDialog .invite-form { grid-template-columns: minmax(0, 1fr) auto; }
  #settingsDialog #inviteEmail { grid-column: 1 / -1; }
  #settingsDialog .member-row { flex-wrap: wrap; }
  #settingsDialog .member-controls { justify-content: flex-start; }
  #settingsDialog .secondary-button, #settingsDialog .danger-button { min-height: 44px; }
  #settingsDialog .owner-row { grid-template-columns: minmax(0, 1fr) 44px; }
  #settingsDialog .owner-row .icon-button { width: 44px; height: 44px; }
  .settings-footer { flex-wrap: wrap; gap: 10px; padding: 14px 18px; }
  #settingsDialog .settings-footer .send-button { width: 100%; }
}

@media (max-width: 380px) {
  #settingsDialog .settings-nav-item { flex-direction: column; font-size: 11px; gap: 5px; }
  .settings-scroll { padding: 22px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #settingsDialog .settings-nav-item, #settingsDialog .settings-switch-row input, #settingsDialog .settings-switch-row input::before { transition: none; }
}

@media (forced-colors: active) {
  #settingsDialog .settings-switch-row input { appearance: auto; }
  #settingsDialog .settings-switch-row input::before { display: none; }
}
