:root {
  --color-big-stone: #141c31;
  --color-dark-spell: #0d1426;
  --color-midnight-green: #113548;
  --color-primary: #145eab;
  --color-primary-600: #0d4f97;
  --color-accent: #f5c84b;
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-line: #dde5f0;
  --color-line-strong: #c8d4e3;
  --color-text: #162033;
  --color-muted: #67748a;
  --color-soft: #eef4fb;
  --color-success: #18855b;
  --color-warning: #a66a00;
  --color-danger: #b42318;
  --radius: 8px;
  --shadow: 0 14px 35px rgba(20, 28, 49, 0.08);
  font-family: "Graphik LCG", "Graphik", Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.35;
}

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

button {
  cursor: pointer;
}

.app-loading {
  padding: 32px;
  color: var(--color-muted);
}

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

.sidenav {
  background: var(--color-big-stone);
  color: #d8e2f0;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 18px;
}

.brand img {
  max-width: 142px;
  height: auto;
}

.nav-group {
  margin-top: 14px;
}

.nav-label {
  color: #8ea0b9;
  font-size: 11px;
  text-transform: uppercase;
  margin: 18px 10px 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  color: #dce8f8;
  background: transparent;
  display: flex;
  gap: 10px;
  align-items: center;
  border-radius: 6px;
  padding: 10px;
  text-align: left;
}

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

.nav-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--color-big-stone);
  background: var(--color-accent);
  font-weight: 700;
  font-size: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 64px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
}

.topbar-hidden {
  display: none;
}

.page-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 14px;
}

.subtitle {
  color: var(--color-muted);
  font-size: 12px;
}

.content {
  padding: 18px 24px 32px;
  min-width: 0;
}

.toolbar,
.view-switch,
.bulkbar,
.detail-actions,
.methodology-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.methodology-actions {
  justify-content: flex-end;
  margin-bottom: 14px;
}

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

.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 78px;
}

.metric .label {
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric .value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 7px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.panel-body {
  padding: 14px;
}

.catalogue-bar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--color-line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(320px, 1fr) auto;
  padding: 10px 14px;
}

.catalogue-bar strong {
  display: block;
  font-size: 15px;
}

.catalogue-bar span {
  color: var(--color-muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.agent-status {
  border-radius: 999px;
  display: inline-flex !important;
  font-weight: 700;
  margin-top: 7px !important;
  padding: 4px 9px;
}

.agent-status.ready {
  background: #eaf6f0;
  color: var(--color-success);
}

.agent-status.missing,
.agent-callout {
  background: #fff4df;
  color: var(--color-warning);
}

.processing-pill {
  align-items: center;
  background: #e7f1fd;
  border: 1px solid #bfd7f4;
  border-radius: 999px;
  color: var(--color-primary);
  display: inline-flex !important;
  font-weight: 700;
  gap: 7px;
  margin-top: 7px !important;
  padding: 4px 9px;
}

.spinner {
  animation: spin 0.75s linear infinite;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  display: inline-block;
  height: 13px;
  width: 13px;
}

.mini-spinner {
  animation: spin 0.75s linear infinite;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

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

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.agent-callout {
  border: 1px solid #f2d7a7;
  border-radius: var(--radius);
  font-weight: 650;
  margin-bottom: 14px;
  padding: 10px 12px;
}

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

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

.action-group {
  align-items: center;
  border-left: 1px solid var(--color-line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 10px;
}

.action-group:first-child {
  border-left: 0;
  padding-left: 0;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--color-line-strong);
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 10px;
  background: #fff;
  color: var(--color-text);
}

.multi-select {
  min-height: 120px;
}

.field-hint {
  color: var(--color-muted);
  display: block;
  font-size: 11px;
  margin-top: 4px;
}

.compact-input {
  max-width: 96px;
  text-align: right;
}

.scenario-select {
  min-width: 150px;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.prompt-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  min-height: 260px;
  white-space: pre-wrap;
}

.btn {
  border: 1px solid var(--color-line-strong);
  background: #fff;
  color: var(--color-text);
  min-height: 34px;
  border-radius: 6px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn:disabled,
.select:disabled {
  cursor: wait;
  opacity: 0.62;
}

.btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--color-primary-600);
  color: #fff;
}

.btn.danger {
  color: var(--color-danger);
}

.btn.icon {
  width: 34px;
  padding: 0;
  justify-content: center;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 155px);
  scrollbar-gutter: stable;
}

.app-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  min-width: 100%;
  table-layout: auto;
}

.app-table th,
.app-table td {
  border-bottom: 1px solid var(--color-line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: middle;
}

.app-table th {
  position: sticky;
  top: 0;
  background: #fff;
  color: #55667f;
  font-size: 12px;
  font-weight: 650;
  z-index: 6;
  overflow: visible;
}

.app-table td {
  overflow: hidden;
}

.app-table tr:hover td {
  background: #f8fbff;
}

.select-col {
  width: 44px;
  min-width: 44px;
  left: 0;
  position: sticky;
  text-align: center;
  z-index: 9;
}

.app-table th.select-col {
  z-index: 12;
}

.app-table td.select-col {
  background: #fff;
}

.th-content {
  align-items: center;
  display: flex;
  gap: 4px;
  min-height: 24px;
  min-width: 0;
  position: relative;
}

.sort-btn,
.static-th-label {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: inherit;
  min-height: 24px;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  text-align: left;
}

.sort-btn span:first-child,
.static-th-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort-btn:hover {
  color: var(--color-primary);
}

.sort-indicator {
  color: var(--color-primary);
  font-size: 11px;
  min-width: 10px;
  text-align: right;
}

.th-filter {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--color-muted);
  flex: 0 0 0;
  font-size: 12px;
  min-height: 22px;
  padding: 0;
  width: 0;
}

.th-filter:hover,
.th-filter.active {
  color: var(--color-primary);
}

.filter-popover {
  background: #fff;
  border: 1px solid var(--color-line);
  box-shadow: 0 14px 32px rgba(15, 22, 32, 0.16);
  display: flex;
  flex-direction: column;
  gap: 4px;
  left: 8px;
  max-height: 260px;
  min-width: 190px;
  overflow: auto;
  padding: 8px;
  position: absolute;
  top: calc(100% - 2px);
  z-index: 40;
}

.filter-popover button {
  background: transparent;
  border: 0;
  color: var(--color-text);
  min-height: 28px;
  padding: 5px 8px;
  text-align: left;
}

.filter-popover button:hover,
.filter-popover button.selected {
  background: #f3f7fc;
  color: var(--color-primary);
}

.search-filter {
  min-width: 260px;
}

.firm-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

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

.enrichment-dot {
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
  height: 8px;
  width: 8px;
}

.enrichment-dot.completed {
  background: var(--color-success);
}

.enrichment-dot.queued {
  background: var(--color-primary);
}

.enrichment-dot.running {
  animation: pulse 1s ease-in-out infinite;
  background: var(--color-warning);
}

.enrichment-dot.failed {
  background: var(--color-danger);
}

.firm-col {
  background: #fff;
  box-shadow: 1px 0 0 rgba(218, 226, 238, 0.85);
  left: 44px;
  position: sticky;
  width: 300px;
  z-index: 8;
}

.app-table th:nth-child(2) {
  box-shadow: 1px 0 0 rgba(218, 226, 238, 0.85);
  left: 44px;
  position: sticky;
  width: 300px;
  z-index: 11;
}

.app-table th:nth-child(3),
.app-table td:nth-child(3) {
  width: 118px;
}

.app-table th:nth-child(4),
.app-table td:nth-child(4) {
  width: 170px;
}

.app-table th:nth-child(5),
.app-table td:nth-child(5) {
  width: 108px;
}

.app-table th:nth-child(6),
.app-table td:nth-child(6) {
  width: 96px;
}

.app-table th:nth-child(7),
.app-table td:nth-child(7) {
  width: 78px;
}

.app-table th:nth-child(8),
.app-table td:nth-child(8) {
  width: 145px;
}

.app-table th:nth-child(9),
.app-table td:nth-child(9) {
  width: 130px;
}

.app-table th:nth-child(10),
.app-table td:nth-child(10) {
  width: 145px;
}

.app-table th:nth-child(11),
.app-table td:nth-child(11) {
  width: 125px;
}

.app-table th:nth-child(12),
.app-table td:nth-child(12) {
  width: 112px;
}

.app-table th:nth-child(13),
.app-table td:nth-child(13) {
  width: 90px;
}

.app-table th:nth-child(14),
.app-table td:nth-child(14) {
  width: 110px;
}

.firm-name {
  color: var(--color-primary);
  font-weight: 650;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}

.muted,
.cell-note {
  color: var(--color-muted);
}

.cell-note {
  max-width: 300px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--color-soft);
  color: #31516f;
  white-space: nowrap;
}

.badge.score {
  background: #eaf6f0;
  color: var(--color-success);
  font-weight: 700;
}

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

.badge.danger {
  background: #ffebe8;
  color: var(--color-danger);
}

.badge.blue {
  background: #e7f1fd;
  color: var(--color-primary);
}

.badge.muted-badge {
  background: #eef2f7;
  color: var(--color-muted);
  font-weight: 700;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--color-line);
}

.pipeline-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.pipeline-board {
  align-items: stretch;
  display: grid;
  gap: 12px;
  grid-auto-columns: 280px;
  grid-auto-flow: column;
  min-height: calc(100vh - 124px);
  min-width: max-content;
}

.pipeline-col {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 560px;
  min-width: 0;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.pipeline-col.drop-hover {
  background: #f5faff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(20, 102, 178, 0.12);
}

.pipeline-col header {
  align-items: start;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 11px 12px;
}

.pipeline-col header span {
  color: var(--color-muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.pipeline-col header > strong {
  background: var(--color-soft);
  border-radius: 999px;
  color: #31516f;
  flex: 0 0 auto;
  font-size: 12px;
  padding: 4px 9px;
}

.pipeline-card-list {
  align-content: start;
  display: grid;
  flex: 1;
  gap: 10px;
  min-height: 180px;
  padding: 10px;
  transition: background 0.15s ease;
}

.pipeline-card-list.drop-hover {
  background: rgba(20, 102, 178, 0.05);
}

.pipeline-card {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: 7px;
  cursor: grab;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.pipeline-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 6px 16px rgba(15, 42, 66, 0.08);
}

.pipeline-card.dragging {
  cursor: grabbing;
  opacity: 0.52;
  transform: scale(0.99);
}

.pipeline-card-main {
  background: transparent;
  border: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.pipeline-meta,
.pipeline-readiness {
  color: var(--color-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
}

.pipeline-card-footer {
  align-items: flex-start;
  border-top: 1px solid var(--color-line);
  display: flex;
  gap: 8px;
  padding: 8px 10px;
}

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

.crm-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  padding: 14px;
}

.crm-table-wrap {
  max-height: calc(100vh - 150px);
}

.crm-table.app-table {
  min-width: 1220px;
}

.crm-table.app-table th:nth-child(1),
.crm-table.app-table td:nth-child(1) {
  width: 220px;
}

.crm-table.app-table th:nth-child(2),
.crm-table.app-table td:nth-child(2) {
  box-shadow: none;
  left: auto;
  position: sticky;
  width: 230px;
  z-index: 6;
}

.crm-table.app-table th:nth-child(3),
.crm-table.app-table td:nth-child(3) {
  width: 190px;
}

.crm-table.app-table th:nth-child(4),
.crm-table.app-table td:nth-child(4) {
  width: 220px;
}

.crm-table.app-table th:nth-child(5),
.crm-table.app-table td:nth-child(5) {
  width: 135px;
}

.crm-table.app-table th:nth-child(6),
.crm-table.app-table td:nth-child(6),
.crm-table.app-table th:nth-child(7),
.crm-table.app-table td:nth-child(7),
.crm-table.app-table th:nth-child(8),
.crm-table.app-table td:nth-child(8),
.crm-table.app-table th:nth-child(9),
.crm-table.app-table td:nth-child(9) {
  width: 100px;
}

.crm-card {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 210px;
}

.crm-card-head,
.crm-card-footer,
.email-subject-row,
.email-item {
  align-items: flex-start;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.crm-card-head {
  border-bottom: 1px solid var(--color-line);
  padding: 12px;
}

.crm-card-head strong,
.email-subject-row strong {
  display: block;
  font-size: 15px;
}

.crm-card-head span,
.crm-card-footer span {
  color: var(--color-muted);
  font-size: 12px;
}

.crm-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}

.crm-card-body p {
  color: var(--color-muted);
  display: -webkit-box;
  font-size: 13px;
  margin: 4px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.crm-card-footer {
  border-top: 1px solid var(--color-line);
  padding: 10px 12px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--color-primary);
  font-weight: 650;
  padding: 0;
  text-align: left;
}

.email-connection-grid {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.email-connection-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.email-actions {
  align-items: center;
  flex-direction: row !important;
  justify-content: flex-end;
}

.oauth-uri-block {
  grid-column: span 2;
}

.oauth-uri-block strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.email-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.email-client {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 520px;
}

.email-workspace {
  display: grid;
  grid-template-columns: 168px minmax(360px, 460px) minmax(0, 1fr);
  height: calc(100vh - 36px);
  min-height: 680px;
  max-height: calc(100vh - 36px);
  overflow: hidden;
}

.email-folders {
  border-right: 1px solid var(--color-line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
}

.compose-sidebar {
  justify-content: center;
  margin-bottom: 8px;
  width: 100%;
}

.settings-link {
  margin-top: auto;
  padding: 9px 10px;
}

.email-folders button,
.task-tabs button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--color-text);
  font-weight: 650;
  padding: 9px 10px;
  text-align: left;
}

.email-folders button.active,
.task-tabs button.active {
  background: #e7f1fd;
  color: var(--color-primary);
}

.email-thread-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: auto;
}

.email-thread-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 52px;
  padding: 9px 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

.email-thread-row {
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  display: grid;
  gap: 10px;
  grid-template-columns: 22px minmax(0, 1fr);
  padding: 13px 14px;
  text-align: left;
  width: 100%;
}

.email-thread-row.unread {
  background: #f8fbff;
  font-weight: 400;
}

.email-thread-row.active {
  background: #eaf3ff;
}

.thread-card {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.thread-card-top {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.thread-card-top strong,
.thread-card-subject,
.thread-card-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-card-top time {
  color: var(--color-muted);
  font-weight: 600;
  white-space: nowrap;
}

.thread-card-subject {
  color: var(--color-text);
  font-weight: 600;
}

.thread-card-top strong {
  font-weight: 600;
}

.email-thread-row:not(.unread) .thread-card-top strong,
.email-thread-row:not(.unread) .thread-card-subject {
  font-weight: 500;
}

.thread-card-preview {
  color: #8d939b;
  font-size: 13px;
  line-height: 1.35;
}

.unread-dot {
  background: var(--color-primary);
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.email-toolbar-actions {
  align-items: center;
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.email-reading-pane {
  background: #fff;
  border-left: 1px solid var(--color-line);
  height: 100%;
  min-width: 0;
  overflow: auto;
  padding: 22px 28px;
}

.email-pane-header {
  border-bottom: 1px solid var(--color-line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.email-pane-header h1 {
  font-size: 24px;
  line-height: 1.2;
}

.email-pane-meta {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  width: 100%;
}

.sender-avatar {
  align-items: center;
  background: #e7f1fd;
  border-radius: 999px;
  color: var(--color-primary);
  display: flex;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.email-pane-sender {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.email-pane-sender span,
.email-pane-meta time {
  color: var(--color-muted);
  font-size: 13px;
}

.email-pane-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-btn {
  align-items: center;
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: 5px;
  color: var(--color-text);
  display: inline-flex;
  height: 26px;
  justify-content: center;
  min-width: 26px;
  padding: 0 7px;
}

.icon-btn.danger {
  color: var(--color-danger);
}

.compact-select {
  border: 1px solid var(--color-line);
  border-radius: 5px;
  color: var(--color-text);
  height: 26px;
  max-width: 145px;
}

.compact-select.has-value {
  border-color: #b8d2ef;
  color: var(--color-primary);
  font-weight: 600;
  max-width: 220px;
}

.checkbox-line {
  align-items: center;
  display: flex;
  gap: 8px;
  font-weight: 700;
}

.thread-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.thread-main span {
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-meta {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.email-item {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 12px;
}

.email-item-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.email-item-main p {
  color: var(--color-muted);
  margin: 2px 0 0;
}

.email-item-side {
  display: flex;
  flex: 0 0 230px;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.email-full-message {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
}

.email-full-message.latest {
  border-color: #b8d2ef;
  box-shadow: 0 8px 22px rgba(27, 112, 185, 0.08);
}

.email-full-message summary {
  list-style: none;
}

.email-full-message summary::-webkit-details-marker {
  display: none;
}

.email-message-summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 11px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  min-height: 62px;
  padding: 12px 14px;
}

.email-full-message.older:not([open]) .email-message-summary {
  background: #fbfcfe;
}

.email-full-message.latest .email-message-summary {
  background: #f7fbff;
}

.message-avatar {
  height: 38px;
  width: 38px;
}

.email-message-summary-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

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

.email-message-title-row strong,
.email-message-summary-main span,
.email-message-summary-main p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-message-summary-main span,
.email-message-summary-main p,
.message-time {
  color: var(--color-muted);
  font-size: 13px;
}

.email-message-summary-main p {
  margin: 0;
}

.email-message-content {
  border-top: 1px solid var(--color-line);
  padding: 14px 16px 16px 63px;
}

.linked-task-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.linked-task-chip {
  background: #f8fbff;
  border: 1px solid #d7e5f5;
  border-radius: 5px;
  color: var(--color-primary);
  font-weight: 600;
  padding: 5px 8px;
}

.email-body {
  background: #fff;
  border: 0;
  color: var(--color-text);
  font-family: inherit;
  line-height: 1.58;
  margin: 12px 0 0;
  max-width: 920px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.email-body p {
  margin: 0 0 12px;
}

.email-body p:last-child {
  margin-bottom: 0;
}

.email-body a {
  color: var(--color-primary);
  font-weight: 600;
}

.email-table-text {
  background: #f8fafc;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  color: #263244;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 12px 0;
  overflow-x: auto;
  padding: 10px 12px;
  white-space: pre;
}

.email-table-text div:first-child {
  color: var(--color-muted);
  font-weight: 700;
}

.email-note-line {
  color: var(--color-text);
  font-weight: 600;
}

.email-summary {
  background: #f8fbff;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  margin-top: 10px;
  padding: 9px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.compose-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.compose-form .form-row {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 90px minmax(0, 1fr);
}

.compose-body {
  min-height: 340px;
}

.task-tabs {
  border-bottom: 1px solid var(--color-line);
  display: flex;
  gap: 4px;
  padding: 10px 12px;
}

.crm-tabs {
  margin: 0 18px 16px;
}

.crm-panel {
  overflow: hidden;
}

.crm-pipeline-scroll,
.crm-enterprise-board {
  padding: 0 18px 18px;
}

.crm-lead-board,
.crm-enterprise-board {
  min-height: calc(100vh - 240px);
}

.crm-lead-board {
  grid-auto-columns: minmax(260px, 1fr);
  min-width: 100%;
}

.crm-lead-board .pipeline-col,
.crm-enterprise-board .pipeline-col {
  min-height: calc(100vh - 260px);
}

.crm-lead-board .pipeline-card-list,
.crm-enterprise-board .pipeline-card-list {
  min-height: 220px;
}

.crm-simple-table-wrap {
  max-height: calc(100vh - 245px);
  margin: 0 18px 18px;
  border: 1px solid var(--color-line);
  border-radius: 0 0 var(--radius) var(--radius);
}

.crm-simple-table.app-table {
  min-width: 980px;
  table-layout: fixed;
  width: 100%;
}

.crm-simple-table.app-table th,
.crm-simple-table.app-table td {
  height: 48px;
  padding: 9px 12px;
}

.crm-simple-table.app-table .firm-col {
  box-shadow: none;
  left: auto;
  position: static;
  width: auto;
  z-index: auto;
}

.crm-simple-table.app-table th:nth-child(1),
.crm-simple-table.app-table td:nth-child(1) {
  box-shadow: none;
  left: auto;
  position: static;
  width: 28%;
}

.crm-simple-table.app-table th:nth-child(2),
.crm-simple-table.app-table td:nth-child(2) {
  box-shadow: none;
  left: auto;
  position: static;
  width: 23%;
}

.crm-simple-table.app-table th:nth-child(3),
.crm-simple-table.app-table td:nth-child(3) {
  width: 14%;
}

.crm-simple-table.app-table th:nth-child(4),
.crm-simple-table.app-table td:nth-child(4),
.crm-simple-table.app-table th:nth-child(5),
.crm-simple-table.app-table td:nth-child(5) {
  width: 13%;
}

.crm-simple-table.app-table th:nth-child(6),
.crm-simple-table.app-table td:nth-child(6) {
  width: 9%;
}

.subscription-table.app-table th:nth-child(1),
.subscription-table.app-table td:nth-child(1),
.subscription-table.app-table th:nth-child(2),
.subscription-table.app-table td:nth-child(2) {
  width: 20%;
}

.subscription-table.app-table th:nth-child(3),
.subscription-table.app-table td:nth-child(3),
.subscription-table.app-table th:nth-child(4),
.subscription-table.app-table td:nth-child(4),
.subscription-table.app-table th:nth-child(5),
.subscription-table.app-table td:nth-child(5),
.subscription-table.app-table th:nth-child(6),
.subscription-table.app-table td:nth-child(6),
.subscription-table.app-table th:nth-child(7),
.subscription-table.app-table td:nth-child(7) {
  width: 10%;
}

.subscription-table.app-table th:nth-child(8),
.subscription-table.app-table td:nth-child(8) {
  width: 8%;
}

.checkbox-grid {
  display: grid;
  gap: 8px 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.checkbox-grid label {
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 8px;
  color: var(--color-text);
  display: flex;
  font-size: 13px;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  min-height: calc(100vh - 198px);
  overflow: auto;
}

.task-col {
  min-height: calc(100vh - 210px);
}

.task-card {
  cursor: grab;
}

.task-col.drop-hover {
  background: #f5faff;
  border-color: var(--color-primary);
}

.contact-email-panel .panel-header {
  border-bottom: 1px solid var(--color-line);
}

.contact-email-list {
  min-height: 360px;
}

.contact-email-row {
  grid-template-columns: 18px 180px minmax(0, 1fr) 110px;
}

.direction-dot {
  border-radius: 999px;
  height: 9px;
  margin-top: 6px;
  width: 9px;
}

.direction-dot.inbound {
  background: var(--color-primary);
}

.direction-dot.outbound {
  background: var(--color-success);
}

.scenario-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.scenario-card {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 12px;
}

.scenario-card div {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.checkbox-field {
  align-items: end;
  display: flex;
}

.contact-tabs {
  border-bottom: 1px solid var(--color-line);
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.contact-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--color-muted);
  font-weight: 650;
  padding: 10px 12px;
}

.contact-tabs button.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.target-contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target-contact-card {
  border: 1px solid var(--color-line);
  border-radius: 7px;
  padding: 10px;
}

.target-contact-card span {
  color: var(--color-muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.target-contact-actions {
  display: flex;
  gap: 10px;
  margin-top: 7px;
}

.dossier-top {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 14px;
}

.dossier-title {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dossier-title h1 {
  font-size: 24px;
  line-height: 1.12;
}

.dossier-summary {
  color: var(--color-muted);
  display: -webkit-box;
  font-size: 14px;
  line-height: 1.35;
  max-width: 980px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mini-metric {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 10px;
}

.mini-metric span {
  display: block;
  color: var(--color-muted);
  font-size: 11px;
}

.mini-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.dossier-metrics {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
}

.detail-grid-full {
  grid-column: 1 / -1;
}

.communication-summary {
  min-height: 220px;
}

.communication-summary-field {
  min-height: 180px;
  resize: vertical;
}

.dossier-layout {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.dossier-main {
  min-width: 0;
}

.dossier-side {
  min-width: 0;
}

.section-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.kv {
  border-bottom: 1px solid var(--color-line);
  padding-bottom: 8px;
}

.kv span {
  display: block;
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.kv strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.side-kv-grid {
  grid-template-columns: 1fr;
}

.financial-formula {
  background: #f8fbff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  margin-bottom: 0;
  padding: 8px;
}

.financial-body {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(280px, 0.7fr) minmax(420px, 1fr);
}

.formula-head,
.formula-total {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.formula-head span,
.formula-item span,
.formula-total span {
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.formula-grid {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr;
  margin: 6px 0;
}

.formula-item {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: 6px;
  padding: 6px 8px;
}

.formula-item strong {
  display: block;
  font-size: 12px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.formula-total {
  border-top: 1px solid var(--color-line);
  padding-top: 6px;
}

.pnl-table {
  width: 100%;
  border-collapse: collapse;
}

.pnl-table th,
.pnl-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-line);
  text-align: right;
}

.pnl-table th:first-child,
.pnl-table td:first-child {
  text-align: left;
}

.pnl-share {
  color: var(--color-muted);
  display: inline-block;
  font-size: 12px;
  margin-left: 8px;
}

.score-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.score-overview {
  align-items: center;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(300px, 0.75fr) minmax(260px, 0.55fr);
  margin-bottom: 16px;
}

.radar {
  height: auto;
  max-width: 420px;
  width: 100%;
}

.radar text {
  fill: #51627a;
  font-size: 12px;
  font-weight: 700;
}

.score-card {
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  padding: 16px;
}

.score-card span {
  color: var(--color-muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.score-card strong {
  background: #e7f1fd;
  border-radius: 8px;
  color: var(--color-primary);
  display: inline-block;
  font-size: 54px;
  line-height: 1;
  margin: 12px 0 10px;
  min-width: 112px;
  padding: 12px 18px;
  text-align: center;
}

.score-card.score strong {
  background: #eaf6f0;
  color: var(--color-success);
}

.score-card.warning strong {
  background: #fff4df;
  color: var(--color-warning);
}

.score-card.danger strong {
  background: #ffebe8;
  color: var(--color-danger);
}

.score-card.unscored strong {
  background: #eef2f7;
  color: var(--color-muted);
}

.score-card em {
  background: #eef2f7;
  border-radius: 999px;
  color: #53647b;
  display: table;
  font-style: normal;
  font-weight: 700;
  padding: 5px 10px;
}

.score-card p {
  color: #354256;
  margin: 12px 0 0;
}

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

.score-axis-card {
  border: 1px solid var(--color-line);
  border-radius: 6px;
  min-height: 116px;
  padding: 12px;
}

.axis-card-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.axis-card-head strong {
  font-size: 16px;
  line-height: 1.2;
}

.axis-card-head span {
  color: var(--color-text);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.score-axis-card p {
  color: #53647b;
  margin: 7px 0 0;
}

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

.axis-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 80px;
  gap: 10px;
  align-items: center;
}

.bar {
  height: 8px;
  background: #e7edf6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--color-primary);
}

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

.timeline-item {
  border-left: 3px solid var(--color-primary);
  padding-left: 10px;
}

.timeline-item strong {
  display: block;
}

.timeline-change-list {
  border: 1px solid var(--color-line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
}

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

.change-row span {
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.change-row strong {
  background: #f8fbff;
  border: 1px solid var(--color-line);
  border-radius: 5px;
  font-weight: 600;
  overflow-wrap: anywhere;
  padding: 5px 7px;
}

.change-row em {
  color: var(--color-muted);
  font-style: normal;
}

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

.signal-item {
  border-bottom: 1px solid var(--color-line);
  padding-bottom: 9px;
}

.signal-item span {
  color: var(--color-muted);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
}

.signal-item strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 20, 38, 0.45);
  display: grid;
  place-items: start center;
  padding: 40px 18px;
  z-index: 20;
  overflow: auto;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--color-line);
  box-shadow: 0 24px 70px rgba(13, 20, 38, 0.22);
  width: min(960px, 100%);
}

.modal.small {
  width: min(620px, 100%);
}

.modal header,
.modal footer {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal footer {
  border-top: 1px solid var(--color-line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal-body {
  padding: 16px;
  max-height: 72vh;
  overflow: auto;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  color: var(--color-muted);
  font-size: 12px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 32px 16px;
  background: #eef3f9;
}

.public-panel {
  width: min(920px, 100%);
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-line);
}

.public-header img {
  height: 28px;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--color-big-stone);
  color: #fff;
  padding: 11px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 1180px) {
  .summary-grid,
  .metrics-row,
  .dossier-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid,
  .dossier-layout,
  .financial-body,
  .score-overview,
  .score-layout {
    grid-template-columns: 1fr;
  }

  .pipeline-board {
    grid-auto-columns: 280px;
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidenav {
    position: static;
    height: auto;
  }

  .table-actions {
    align-items: stretch;
    flex-wrap: wrap;
    white-space: normal;
  }

  .table-actions .btn {
    flex: 1 1 160px;
  }

  .catalogue-bar {
    grid-template-columns: 1fr;
  }

  .catalogue-actions {
    justify-content: flex-start;
  }

  .action-group {
    border-left: 0;
    border-top: 1px solid var(--color-line);
    padding-left: 0;
    padding-top: 8px;
  }

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

  .dossier-top {
    grid-template-columns: 1fr;
  }

  .change-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .pipeline-board {
    grid-auto-columns: 260px;
  }
}
