:root {
  --ink: #111116;
  --muted: #696974;
  --line: rgba(17, 17, 22, 0.09);
  --surface: #ffffff;
  --page: #f4f4f6;
  --soft: #f8f7ff;
  --accent: #7861ff;
  --danger: #b91c1c;
  --ok: #057a55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

a {
  color: inherit;
}

.crm-body {
  background: var(--page);
}

.crm-layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
}

.crm-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 286px;
  min-width: 286px;
  height: 100vh;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 24px rgba(16, 16, 20, 0.04);
}

.brand-account-menu summary {
  list-style: none;
}

.brand-account-menu summary::-webkit-details-marker {
  display: none;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 74px;
  padding: 0.66rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 9px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 900;
  background: #fff;
}

.brand-mark img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.rai-signature {
  position: fixed;
  right: 1rem;
  bottom: 0.75rem;
  z-index: 20;
  padding: 0.32rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
}

.brand-copy {
  display: grid;
  gap: 0.12rem;
}

.brand-copy strong {
  font-size: 1rem;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.account-menu-panel {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.account-menu-identity,
.account-menu-action {
  display: grid;
  gap: 0.12rem;
  width: 100%;
  padding: 0.58rem 0.68rem;
  border-radius: 8px;
  background: #f7f7f9;
}

.account-menu-identity span {
  color: var(--muted);
  font-size: 0.72rem;
}

.account-menu-action,
button {
  min-height: 2.35rem;
  border: 0;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
  background: #f5f5f7;
  cursor: pointer;
}

button {
  padding: 0.56rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}

button:hover,
.nav-link:hover {
  background: rgba(120, 97, 255, 0.12);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  width: 100%;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.language-switcher button {
  min-height: 2rem;
  padding: 0.35rem;
  border-radius: 8px;
  font-size: 0.78rem;
}

.language-switcher button.is-active {
  color: #fff;
  background: #000;
}

.nav-link {
  display: grid;
  gap: 0.15rem;
  min-height: 48px;
  padding: 0.56rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.72);
}

.nav-link strong {
  font-size: 0.92rem;
}

.nav-link span {
  color: var(--muted);
  font-size: 0.72rem;
}

.nav-link.is-active {
  color: #fff;
  background: #000;
  border-color: #000;
  box-shadow: none;
}

.nav-link.is-active span {
  color: #fff;
}

.crm-main {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  width: 100%;
  max-width: 1560px;
  min-width: 0;
  padding: 1.05rem clamp(1rem, 2vw, 1.7rem) 2rem;
}

.page-header,
.workspace-panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(16, 16, 20, 0.045);
}

.page-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.1rem;
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.45rem, 2vw, 2.15rem);
  line-height: 1.08;
}

.page-description,
.workspace-panel p,
td span {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.stat-card {
  display: grid;
  gap: 0.25rem;
  min-height: 96px;
  padding: 1rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-card strong {
  font-size: 1.9rem;
}

.sensor-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.dashboard-grid,
.settings-grid,
.assistant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.finder-panel {
  margin-top: 0.9rem;
}

.finder-panel .panel-head {
  align-items: center;
  margin-bottom: 0.85rem;
}

.finder-panel .panel-head form {
  margin: 0;
}

.finder-panel .panel-head button {
  min-height: 2.6rem;
  padding: 0.55rem 0.9rem;
}

.finder-panel .panel-head button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.finder-account {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.finder-account span,
.notice {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  background: #f7f7f9;
}

.finder-account strong {
  color: #111;
}

.notice {
  display: inline-block;
  margin: 0 0 0.8rem;
}

.flood-wait-alert {
  display: grid;
  gap: 0.25rem;
  margin: 0 0 0.9rem;
  border-width: 2px;
}

.flood-wait-alert strong,
.flood-wait-alert span {
  display: block;
}

.flood-wait-alert span {
  font-size: 0.86rem;
  font-weight: 800;
}

.finder-metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.finder-metrics div {
  min-height: 74px;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.finder-metrics span,
.finder-metrics strong {
  display: block;
}

.finder-metrics span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
}

.finder-metrics strong {
  margin-top: 0.3rem;
  font-size: 1.35rem;
}

.finder-jobs-table {
  margin-top: 0.5rem;
}

.finder-more {
  margin-top: 0.55rem;
}

.finder-more summary {
  cursor: pointer;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #111;
  font-size: 0.82rem;
  font-weight: 900;
  background: #f7f7f9;
}

.finder-leads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 0.5rem;
}

.finder-leads-head h3 {
  margin: 0;
  font-size: 1rem;
}

.finder-leads-head a {
  color: #111;
  font-size: 0.82rem;
  font-weight: 900;
}

.finder-leads-table td {
  vertical-align: top;
}

.finder-leads-table {
  table-layout: fixed;
}

.finder-leads-table th:nth-child(1),
.finder-leads-table td:nth-child(1) {
  width: 12%;
}

.finder-leads-table th:nth-child(2),
.finder-leads-table td:nth-child(2) {
  width: 15%;
}

.finder-leads-table th:nth-child(3),
.finder-leads-table td:nth-child(3) {
  width: 16%;
}

.finder-leads-table th:nth-child(4),
.finder-leads-table td:nth-child(4),
.finder-leads-table th:nth-child(5),
.finder-leads-table td:nth-child(5) {
  width: 28.5%;
}

.finder-leads-table .badge {
  margin-bottom: 0.28rem;
}

.finder-keywords {
  color: #111;
  font-weight: 800;
}

.finder-message {
  display: -webkit-box;
  max-width: 100%;
  max-height: 4.2rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  word-break: break-word;
}

.finder-leads-table td:nth-child(5) span {
  display: -webkit-box;
  max-height: 4.2rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  word-break: break-word;
}

.leads-panel {
  overflow: visible;
}

.lead-list {
  display: grid;
  gap: 0.75rem;
}

.lead-card {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.lead-card-main,
.lead-card-grid,
.lead-badges,
.lead-actions {
  display: flex;
  gap: 0.6rem;
}

.lead-card-main {
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.lead-person strong,
.lead-person span,
.lead-block strong,
.lead-block p,
.lead-label {
  display: block;
}

.lead-person strong {
  color: #101018;
  font-size: 1rem;
  line-height: 1.15;
}

.lead-person span {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.lead-badges {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lead-score {
  padding: 0.28rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #101018;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
  background: #f7f7f9;
}

.lead-card-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.15fr) minmax(240px, 1fr) minmax(170px, 0.65fr) 104px;
  gap: 0.85rem;
  align-items: start;
  padding-top: 0.8rem;
}

.lead-block {
  min-width: 0;
}

.lead-label {
  margin-bottom: 0.22rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.lead-block a,
.lead-block strong {
  color: #111;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.lead-block p {
  display: -webkit-box;
  margin: 0.25rem 0 0;
  max-height: 4.6rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.lead-status-block p + .lead-label {
  margin-top: 0.6rem;
}

.lead-actions {
  flex-direction: column;
  align-items: stretch;
}

.lead-actions form {
  margin: 0;
}

.lead-actions button {
  width: 100%;
  min-height: 2.15rem;
  padding: 0.35rem 0.6rem;
  border-radius: 10px;
  white-space: nowrap;
}

.settings-form {
  display: grid;
  gap: 0.75rem;
}

.settings-connect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.settings-panel {
  padding: 0.85rem;
}

.settings-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.settings-panel .panel-head {
  align-items: center;
  margin-bottom: 0.65rem;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.58rem;
}

.settings-fields label {
  font-size: 0.72rem;
}

.settings-fields input,
.settings-fields select {
  min-height: 2.25rem;
  padding: 0.48rem 0.58rem;
  border-radius: 8px;
  font-size: 0.84rem;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-save-row {
  padding-top: 0.1rem;
}

.settings-actions button {
  min-width: 184px;
  min-height: 2.35rem;
  color: #fff;
  background: #000;
}

.workspace-panel {
  padding: 0.95rem;
  overflow: hidden;
}

.workspace-panel h2 {
  margin: 0 0 0.55rem;
  font-size: 1.12rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.panel-head p {
  margin: 0.2rem 0 0;
  max-width: 620px;
  font-size: 0.86rem;
  line-height: 1.35;
}

.status-list {
  display: grid;
  gap: 0.6rem;
}

.status-list div,
.compact-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem;
  border-radius: 8px;
  background: #f7f7f9;
}

.status-list span,
.compact-list span {
  color: var(--muted);
  font-size: 0.82rem;
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.sensor {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 72px;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7f7f9;
}

.sensor strong,
.sensor span {
  display: block;
}

.sensor strong {
  font-size: 0.96rem;
}

.sensor div span {
  margin-top: 0.14rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.sensor-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #a1a1aa;
  box-shadow: 0 0 0 6px rgba(161, 161, 170, 0.14);
}

.sensor-ok .sensor-dot {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(5, 122, 85, 0.14);
}

.sensor-error .sensor-dot {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(185, 28, 28, 0.14);
}

.sensor-disabled .sensor-dot {
  background: #71717a;
}

.notice-panel {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(5, 122, 85, 0.24);
  border-radius: 9px;
  color: #065f46;
  font-weight: 800;
  background: #ecfdf5;
}

.notice-error {
  border-color: rgba(185, 28, 28, 0.24);
  color: var(--danger);
  background: #fff2f2;
}

.notice-warning {
  border-color: rgba(217, 119, 6, 0.28);
  color: #92400e;
  background: #fff7ed;
}

.notice-muted {
  border-color: rgba(113, 113, 122, 0.24);
  color: #52525b;
  background: #f4f4f5;
}

.compact-list {
  display: grid;
  gap: 0.5rem;
}

.compact-list a {
  color: inherit;
  text-decoration: none;
}

.empty-state {
  margin: 0;
  padding: 1rem;
  border: 1px dashed rgba(17, 17, 22, 0.2);
  border-radius: 12px;
  background: #fafafa;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.topic-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.topic-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
  align-items: stretch;
}

.topic-submit {
  justify-self: end;
  align-self: end;
  width: auto;
  min-width: 116px;
  min-height: 2.55rem;
  padding-inline: 1.1rem;
  color: #fff;
  background: #000;
}

.topic-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.channel-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-height: 2.4rem;
  padding: 0.42rem 0;
  border: 1px solid var(--line);
  border-width: 1px 0 0;
  border-radius: 0;
  background: transparent;
}

.channel-picker span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.channel-picker label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink);
}

.channel-picker input {
  width: auto;
  min-height: 0;
}

.tag-editor {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 4.9rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: text;
}

.tag-list {
  display: contents;
}

.tag-chip {
  min-height: 1.85rem;
  padding: 0.24rem 0.58rem;
  border-radius: 999px;
  color: #111116;
  font-size: 0.78rem;
  font-weight: 800;
  background: #f0f0f3;
}

.tag-chip:hover {
  background: #e8e8ee;
}

.tag-input {
  flex: 1 1 190px;
  min-width: 160px;
  min-height: 2rem;
  padding: 0.2rem;
  border: 0;
  outline: 0;
}

input,
textarea,
select {
  width: 100%;
  min-height: 2.55rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.prompt-area {
  min-height: 150px;
  line-height: 1.5;
}

.file-form,
.clean-form,
.upload-widget {
  display: grid;
  gap: 0.58rem;
  margin-top: 0.75rem;
}

.upload-widget + .upload-widget {
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.upload-widget-link {
  margin-top: 0.65rem;
}

.assistant-two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.55fr);
  gap: 0.58rem;
}

.file-form button,
.clean-form button,
.upload-widget button {
  min-width: 104px;
  min-height: 2.25rem;
  padding: 0.42rem 0.72rem;
  font-size: 0.8rem;
}

.upload-actions {
  display: flex;
  justify-content: flex-end;
}

.usage-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e8ee;
}

.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #111116;
}

.assistant-prompt-panel {
  max-width: 1120px;
}

.assistant-panel {
  font-size: 0.92rem;
}

.assistant-panel h2 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.assistant-panel label {
  font-size: 0.74rem;
}

.assistant-panel input,
.assistant-panel textarea,
.assistant-panel select {
  min-height: 2.25rem;
  padding: 0.48rem 0.58rem;
  border-radius: 8px;
  font-size: 0.86rem;
}

.assistant-panel input[type="file"] {
  min-height: 2.35rem;
  padding: 0.42rem;
  overflow: hidden;
  background: #fafafa;
}

.assistant-panel input[type="file"]::file-selector-button {
  margin-right: 0.7rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-weight: 800;
  background: #fff;
  cursor: pointer;
}

.compact-head {
  align-items: center;
}

.quiet-meta {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  background: #fff;
}

.resource-list {
  display: grid;
  gap: 0.45rem;
}

.resource-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.6rem;
  align-items: center;
  min-height: 58px;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.resource-row strong,
.resource-row span {
  display: block;
}

.resource-row div {
  min-width: 0;
}

.resource-row div span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button {
  min-height: 1.9rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  background: #fff;
}

.span-2 {
  grid-column: span 2;
}

.crm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.crm-table th,
.crm-table td {
  padding: 0.72rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.crm-table th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  background: #f7f7f9;
}

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

.crm-table td {
  font-size: 0.9rem;
}

.crm-table td strong,
.crm-table td span {
  display: block;
}

.crm-table td span {
  max-width: 520px;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  line-height: 1.4;
}

.table-link {
  color: inherit;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.dialogue-list {
  display: grid;
  gap: 0.55rem;
}

.dialogue-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  min-height: 78px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dialogue-card:hover {
  border-color: rgba(17, 17, 22, 0.18);
  background: #f9f9fb;
  transform: translateY(-1px);
}

.dialogue-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  text-transform: uppercase;
  background: #111116;
}

.dialogue-avatar-large {
  width: 48px;
  height: 48px;
}

.dialogue-card-main {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.dialogue-card-top,
.dialogue-card-sub,
.dialogue-card-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialogue-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.dialogue-card-top strong {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialogue-card-top time,
.dialogue-card-sub,
.dialogue-card-preview,
.chat-time,
.chat-technical,
.chat-context {
  color: var(--muted);
  font-size: 0.76rem;
}

.dialogue-card-top time {
  flex: 0 0 auto;
}

.dialogue-card-preview {
  color: #4f4f59;
  font-size: 0.84rem;
  line-height: 1.35;
}

.dialogue-card-preview b {
  color: var(--ink);
}

.dialogue-count {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.45rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 900;
  background: #111116;
}

.dialogue-shell {
  display: grid;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.chat-header {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  min-height: 74px;
  padding: 0.8rem 0.95rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.chat-back {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
  background: #f7f7f9;
}

.chat-identity {
  min-width: 0;
}

.chat-identity h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-identity p {
  margin: 0.15rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-source-link {
  min-height: 2rem;
  padding: 0.38rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
  background: #f7f7f9;
}

.dialogue-summary {
  margin: 0.8rem 0.95rem 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(5, 122, 85, 0.18);
  border-radius: 9px;
  color: #064e3b;
  font-size: 0.82rem;
  font-weight: 800;
  background: #ecfdf5;
}

.chat-timeline {
  display: grid;
  gap: 0.58rem;
  min-height: 520px;
  padding: 0.85rem 0.95rem 1rem;
  background:
    radial-gradient(circle at 16px 16px, rgba(17, 17, 22, 0.035) 1.2px, transparent 1.2px) 0 0 / 28px 28px,
    #f2f2f4;
}

.chat-context {
  justify-self: center;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  max-width: 760px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.chat-message {
  display: grid;
  gap: 0.24rem;
  width: min(72%, 780px);
}

.chat-message-in {
  justify-self: start;
}

.chat-message-out {
  justify-self: end;
}

.chat-bubble {
  position: relative;
  padding: 0.62rem 0.72rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(16, 16, 20, 0.035);
}

.chat-message-in .chat-bubble {
  border-top-left-radius: 5px;
  background: #fff;
}

.chat-message-out .chat-bubble {
  border-top-right-radius: 5px;
  color: #fff;
  background: #111116;
}

.chat-bubble p {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  line-height: 1.42;
  white-space: pre-wrap;
}

.chat-author {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.chat-message-out .chat-author {
  color: rgba(255, 255, 255, 0.7);
}

.chat-message-out .chat-time {
  color: rgba(255, 255, 255, 0.68);
}

.chat-time {
  display: block;
  text-align: right;
}

.chat-technical {
  padding: 0 0.25rem;
}

.chat-message-out .chat-technical {
  justify-self: end;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.actions form {
  margin: 0;
}

.actions button {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-height: 1.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  background: #000;
}

.badge-ok {
  background: var(--ok);
}

.badge-disabled {
  background: #71717a;
}

.badge-error {
  background: var(--danger);
}

.badge-warning {
  color: #7c2d12;
  background: #f59e0b;
}

.inline-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px auto;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.32rem 0.45rem 0.32rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
}

.keyword-chip small {
  color: var(--muted);
  font-size: 0.68rem;
}

.keyword-chip button {
  display: grid;
  place-items: center;
  min-width: 1.45rem;
  min-height: 1.45rem;
  padding: 0;
  border-radius: 50%;
}

.keyword-negative {
  background: #fff2f2;
}

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(120, 97, 255, 0.16), transparent 28rem),
    #f4f4f6;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  width: min(420px, 100%);
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(16, 16, 20, 0.1);
}

.auth-mark {
  margin-bottom: 1rem;
}

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

.auth-form {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.auth-form button {
  color: #fff;
  background: #000;
}

.auth-error {
  margin-top: 1rem;
  padding: 0.7rem;
  border-radius: 12px;
  color: var(--danger);
  background: #fff2f2;
}

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

  .crm-sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
  }

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

  .stats-grid,
  .sensor-strip,
  .dashboard-grid,
  .finder-metrics,
  .assistant-grid,
  .topic-create-grid,
  .sensor-grid,
  .settings-grid,
  .settings-connect-grid,
  .settings-fields,
  .topic-form,
  .topic-form-keywords,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .topic-keywords,
  .topic-form-join .topic-keywords,
  .topic-form-keywords .topic-keywords {
    grid-column: auto;
  }

  .inline-controls {
    grid-template-columns: 1fr;
  }

  .file-form,
  .clean-form,
  .clean-form-link,
  .clean-form-media,
  .assistant-two-col,
  .resource-row,
  .lead-card-grid {
    grid-template-columns: 1fr;
  }

  .lead-card-main {
    flex-direction: column;
    gap: 0.55rem;
  }

  .lead-badges {
    justify-content: flex-start;
  }

  .lead-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .lead-actions form {
    flex: 0 0 auto;
  }

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

  .dialogue-count {
    display: none;
  }

  .dialogue-card-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.12rem;
  }

  .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .chat-source-link {
    grid-column: 3;
    justify-self: start;
  }

  .chat-message {
    width: min(92%, 680px);
  }
}
