/* Host pane: inbox view fills shell */
.td-inbox-host {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.td-inbox-host > .td-inbox {
  flex: 1;
  min-height: 0;
  height: auto;
}

/* Premium CRM inbox — scoped under .td-inbox */
.td-inbox {
  --td-inbox-list-width: min(360px, 38vw);
  --td-inbox-radius: 10px;
  --td-inbox-transition: 0.18s ease;
  display: flex;
  height: 100%;
  min-height: 0;
  background: var(--surface-2, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

.td-inbox__thread-col {
  width: var(--td-inbox-list-width);
  min-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  min-height: 0;
}

.td-inbox__conv-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-2, #f8fafc);
}

/* When a thread is open, #conversationView loses .td-inbox__placeholder (which had flex:1).
   Without this flex column, .td-inbox__message-list never gets a max height and nothing scrolls. */
.td-inbox__conv-col #conversationView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.td-inbox__toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
}

.td-inbox__toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
}

.td-inbox__back-to-record {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-primary, #0f172a);
  cursor: pointer;
  transition: background var(--td-inbox-transition), border-color var(--td-inbox-transition);
}

.td-inbox__back-to-record:hover {
  background: var(--surface-hover, #f1f5f9);
  border-color: var(--border-strong, #cbd5e1);
}

.td-inbox__toolbar-title-row .td-inbox__title {
  flex: 1;
  min-width: 0;
}

.td-inbox__msg-engagement {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.td-inbox__eng-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-hover, #f8fafc);
  color: var(--text-secondary, #64748b);
  max-width: 100%;
}

.td-inbox__eng-pill--open {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
  color: #166534;
}

.td-inbox__eng-pill--click {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
  color: #1d4ed8;
}

.td-inbox__title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary, #0f172a);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.td-inbox__toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Accent "New" button — solid pill, consistent height with icon buttons */
.td-inbox__btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent, #2563eb);
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: filter 0.15s;
}
.td-inbox__btn-accent:hover {
  filter: brightness(1.08);
}

/* Small icon buttons (refresh, more) — same height as accent pill */
.td-inbox__icon-btn--sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
}

/* "More" overflow dropdown */
.td-inbox__more-wrap {
  position: relative;
}
.td-inbox__more-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 200px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.14);
  z-index: 55;
}
.td-inbox__more-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-primary, #0f172a);
}
.td-inbox__more-dropdown button:hover {
  background: var(--surface-hover, #f1f5f9);
}

/* Mailbox segmented row (Inbox / Sent / Archived) */
.td-inbox__mailbox-bar {
  display: flex;
  gap: 0;
  margin-bottom: 6px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-1, #fff);
}
.td-inbox__mailbox-bar .td-inbox__mailbox-tab {
  flex: 1;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  border: none;
  border-right: 1px solid var(--border, #e2e8f0);
  background: transparent;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  text-align: center;
}
.td-inbox__mailbox-bar .td-inbox__mailbox-tab:last-child {
  border-right: none;
}
.td-inbox__mailbox-bar .td-inbox__mailbox-tab:hover {
  background: var(--surface-2, #f8fafc);
  color: var(--text-primary, #0f172a);
}
.td-inbox__mailbox-bar .td-inbox__mailbox-tab--active {
  background: var(--accent, #2563eb);
  color: #fff;
}

.td-inbox__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  transition: background var(--td-inbox-transition), color var(--td-inbox-transition);
}

.td-inbox__icon-btn:hover {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

/* Conversation overflow: readable dots + comfortable tap target */
.td-inbox__icon-btn--kebab {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.td-inbox__kebab {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
  color: var(--text-primary, #334155);
}

.td-inbox__search-wrap {
  position: relative;
}

.td-inbox__search {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--td-inbox-radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-2, #f8fafc);
  color: var(--text-primary, #0f172a);
}

/* styles-polish.css sets input[type="search"] { padding: 8px 12px !important } — restore room for both icons */
.td-inbox__search-wrap .td-inbox__search {
  padding: 8px 38px 8px 36px !important;
}

.td-inbox__search:focus {
  outline: 2px solid color-mix(in srgb, var(--accent, #2563eb) 35%, transparent);
  outline-offset: 0;
  border-color: var(--accent, #2563eb);
  background: var(--surface-1, #fff);
}

.td-inbox__search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  opacity: 0.45;
  pointer-events: none;
}

/* Filter icon inside the search bar */
.td-inbox__search-filter-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.td-inbox__search-filter-btn:hover {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

.td-inbox__adv-search {
  margin-top: 4px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--td-inbox-radius, 10px);
  background: var(--surface-1, #fff);
  padding: 4px 8px 8px;
  font-size: 12px;
}

/* Single-row scrollable chip filter bar */
/* Filter chip row (All / Unread / Mine / …) — wraps, never scrolls */
.td-inbox__filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 0 2px;
}
.td-inbox__chip-filter {
  flex-shrink: 0;
  padding: 4px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface-2, #f1f5f9);
  color: var(--text-secondary, #64748b);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.td-inbox__chip-filter:hover {
  background: var(--surface-hover, #e2e8f0);
  color: var(--text-primary, #0f172a);
}
.td-inbox__chip-filter--active {
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, #fff);
  color: var(--accent, #2563eb);
  border-color: color-mix(in srgb, var(--accent, #2563eb) 30%, transparent);
}

.td-inbox__adv-search-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  padding: 4px 2px;
  list-style: none;
}

.td-inbox__adv-search-summary::-webkit-details-marker {
  display: none;
}

.td-inbox__adv-search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  margin-top: 8px;
}

.td-inbox__adv-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-secondary, #64748b);
  font-weight: 500;
}

.td-inbox__adv-field--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-top: 22px;
}

.td-inbox__adv-field--span {
  grid-column: 1 / -1;
}

.td-inbox__adv-input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-2, #f8fafc);
  color: var(--text-primary, #0f172a);
}

.td-inbox__adv-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 767px) {
  .td-inbox__adv-search-grid {
    grid-template-columns: 1fr;
  }

  .td-inbox__adv-field--check {
    padding-top: 0;
  }
}

.td-inbox__mailbox {
  display: flex;
  gap: 6px;
  padding: 2px 0 2px;
}

.td-inbox__mailbox-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface-1, #fff);
  color: var(--text-secondary, #64748b);
  transition:
    background var(--td-inbox-transition),
    color var(--td-inbox-transition),
    border-color var(--td-inbox-transition);
}

.td-inbox__mailbox-tab:hover {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

.td-inbox__mailbox-tab--active {
  border-color: color-mix(in srgb, var(--accent, #2563eb) 45%, var(--border, #e2e8f0));
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--surface-1, #fff));
  color: var(--accent, #2563eb);
}

.td-inbox__filters {
  display: flex;
  gap: 4px;
}

.td-inbox__filter {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary, #64748b);
  transition: background var(--td-inbox-transition), color var(--td-inbox-transition);
}

.td-inbox__filter:hover {
  background: var(--surface-hover, #f1f5f9);
  color: var(--text-primary, #0f172a);
}

.td-inbox__filter--active {
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
  color: var(--accent, #2563eb);
}

.td-inbox__list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-gutter: stable;
}

.td-inbox__empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
}

/* Helper / label tone — keep compact (do not use list-empty padding here). */
.td-inbox__hint {
  margin: 0;
  padding: 0;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

.td-inbox__skeleton {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-hover, #f1f5f9);
  animation: td-inbox-pulse 1.2s ease-in-out infinite;
}

@keyframes td-inbox-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.td-inbox__skeleton-line {
  height: 10px;
  border-radius: 4px;
  background: var(--border, #e2e8f0);
  margin-bottom: 8px;
}

.td-inbox__thread {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--surface-hover, #f1f5f9);
  cursor: pointer;
  text-align: left;
  transition: background var(--td-inbox-transition);
}

.td-inbox__thread:hover {
  background: var(--surface-hover, #f8fafc);
}

.td-inbox__thread--selected {
  background: var(--surface-hover, #f1f5f9);
}

.td-inbox__thread--unread {
  background: var(--surface-2, #f8fafc);
}

.td-inbox__thread--selected.td-inbox__thread--unread {
  background: color-mix(in srgb, var(--accent, #2563eb) 6%, var(--surface-hover, #f1f5f9));
}

.td-inbox__thread-accent {
  width: 3px;
  flex-shrink: 0;
  border-radius: 0 2px 2px 0;
  background: transparent;
}

.td-inbox__thread--unread .td-inbox__thread-accent {
  background: var(--accent, #2563eb);
}

.td-inbox__thread-body {
  flex: 1;
  min-width: 0;
  padding: 12px 12px 12px 10px;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
}

.td-inbox__avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent, #2563eb) 18%, var(--surface-1, #fff));
  color: var(--accent, #2563eb);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.td-inbox__thread-main {
  min-width: 0;
}

.td-inbox__thread-row1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.td-inbox__thread-from {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-inbox__thread-time {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  flex-shrink: 0;
}

.td-inbox__thread-row2 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.td-inbox__thread-subject {
  font-size: 14px;
  color: var(--text-primary, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.td-inbox__thread--unread .td-inbox__thread-subject {
  font-weight: 700;
}

.td-inbox__thread:not(.td-inbox__thread--unread) .td-inbox__thread-subject {
  font-weight: 500;
}

.td-inbox__thread-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.td-inbox__unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent, #2563eb);
  flex-shrink: 0;
  margin-top: 5px;
}

.td-inbox__unread-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent, #2563eb);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.td-inbox__thread-snippet {
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-inbox__thread--unread .td-inbox__thread-snippet {
  font-weight: 500;
  color: var(--text-primary, #0f172a);
}

.td-inbox__thread:not(.td-inbox__thread--unread) .td-inbox__thread-snippet {
  font-weight: 400;
  color: var(--text-secondary, #64748b);
}

.td-inbox__placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
  padding: 24px;
}

.td-inbox__conv-header {
  flex-shrink: 0;
  padding: 6px 12px 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.td-inbox__conv-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.td-inbox__conv-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  margin: 0;
  line-height: 1.25;
}

.td-inbox__conv-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.td-inbox__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.td-inbox__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, transparent);
  color: var(--accent, #2563eb);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: filter var(--td-inbox-transition);
}

.td-inbox__chip:hover {
  filter: brightness(0.95);
}

.td-inbox__chip--muted {
  background: var(--surface-2, #f1f5f9);
  color: var(--text-secondary, #64748b);
}

.td-inbox__participants {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-secondary, #64748b);
}

.td-inbox__dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 200px;
  padding: 6px;
  border-radius: var(--td-inbox-radius);
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
  z-index: 50;
}

.td-inbox__dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-primary, #0f172a);
}

.td-inbox__dropdown button:hover {
  background: var(--surface-hover, #f1f5f9);
}

.td-inbox__message-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  scrollbar-gutter: stable;
}

.td-inbox__msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
}

.td-inbox__msg--out {
  align-self: flex-end;
}

.td-inbox__msg--in {
  align-self: flex-start;
}

.td-inbox__msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
}

.td-inbox__msg--out .td-inbox__msg-bubble {
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, var(--surface-1, #fff));
  border-color: color-mix(in srgb, var(--accent, #2563eb) 22%, var(--border, #e2e8f0));
  border-bottom-right-radius: 4px;
}

.td-inbox__msg--in .td-inbox__msg-bubble {
  border-bottom-left-radius: 4px;
}

.td-inbox__msg-meta {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-bottom: 6px;
}

.td-inbox__msg-body {
  color: var(--text-primary, #0f172a);
  line-height: 1.55;
  font-size: 14px;
  word-break: break-word;
}

.td-inbox__msg-body--plain {
  white-space: pre-wrap;
}

.td-inbox__msg-html {
  max-width: 100%;
  overflow-x: auto;
}

.td-inbox__msg-html img {
  max-width: 100%;
  height: auto;
}

.td-inbox__msg-toggle {
  margin-top: 8px;
  font-size: 12px;
  border: none;
  background: none;
  color: var(--accent, #2563eb);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-weight: 600;
}

.td-inbox__attachments {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, #e2e8f0);
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

.td-inbox__att-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.td-inbox__att-name {
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  word-break: break-word;
}

.td-inbox__att-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.td-inbox__att-action {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-2, #f8fafc);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--accent, #2563eb);
}

.td-inbox__att-action:hover {
  background: var(--surface-hover, #f1f5f9);
}

.td-inbox__att-note {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
}

.td-inbox__btn-secondary {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-primary, #0f172a);
}

.td-inbox__btn-secondary:hover {
  background: var(--surface-hover, #f8fafc);
}

.td-inbox__filters--wrap {
  flex-wrap: wrap;
}

.td-inbox__select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-1, #fff);
  color: var(--text-primary, #0f172a);
}

.td-inbox__suggest-row {
  margin-top: 2px;
}

.td-inbox__preview-modal {
  width: min(920px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-1, #fff);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
}

.td-inbox__preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.td-inbox__preview-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-inbox__preview-frame {
  width: 100%;
  flex: 1;
  min-height: 70vh;
  border: none;
  background: var(--surface-2, #f1f5f9);
}

.td-inbox__textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--surface-1, #fff);
  color: var(--text-primary, #0f172a);
}

/* Collapsible reply strip — keeps the thread list readable */
.td-inbox__composer-shell {
  flex-shrink: 0;
  background: var(--surface-1, #fff);
  border-top: 1px solid var(--border, #e2e8f0);
}

.td-inbox__composer-panel {
  margin: 0;
}

.td-inbox__composer-panel > .td-inbox__composer-panel-summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 52px 12px 16px;
  font-size: 13px;
  color: var(--text-primary, #0f172a);
  user-select: none;
}

.td-inbox__composer-panel > .td-inbox__composer-panel-summary::-webkit-details-marker {
  display: none;
}

.td-inbox__composer-panel > .td-inbox__composer-panel-summary::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  color: var(--text-tertiary, #64748b);
  font-size: 36px;
}

.td-inbox__composer-panel:not([open]) > .td-inbox__composer-panel-summary::after {
  content: "▸";
}

.td-inbox__composer-panel[open] > .td-inbox__composer-panel-summary {
  border-bottom: 1px solid var(--border-light, #f1f5f9);
}

.td-inbox__composer-panel-title {
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.td-inbox__composer-panel-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.td-inbox__composer-panel-subject {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(360px, 48vw);
}

.td-inbox__composer-panel-kbd {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary, #94a3b8);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2, #f1f5f9);
}

.td-inbox__composer-panel-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.td-inbox__composer-panel-body .td-inbox__composer-row textarea {
  min-height: 72px;
}

.td-inbox__composer-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.td-inbox__composer-row label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary, #94a3b8);
}

.td-inbox__composer-row input,
.td-inbox__composer-row textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-1, #fff);
  color: var(--text-primary, #0f172a);
}

.td-inbox__composer-row textarea {
  min-height: 88px;
  resize: vertical;
}

.td-inbox__composer-extras summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  user-select: none;
}

.td-inbox__attach-row {
  margin: 2px 0 10px;
}

.td-inbox__attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.td-inbox__attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-2, #f8fafc);
  font-size: 12px;
  line-height: 1.3;
}

.td-inbox__attach-chip-name {
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(240px, 70vw);
}

.td-inbox__attach-chip-meta {
  color: var(--text-secondary, #64748b);
  flex-shrink: 0;
  font-size: 11px;
}

.td-inbox__attach-chip-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  margin-left: 2px;
  color: var(--text-secondary, #64748b);
  border-radius: 4px;
}

.td-inbox__attach-chip-remove:hover {
  color: #b91c1c;
  background: rgba(185, 28, 28, 0.08);
}

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

.td-inbox__btn-primary {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent, #2563eb);
  color: #fff;
  transition: filter var(--td-inbox-transition);
}

.td-inbox__btn-primary:hover {
  filter: brightness(1.05);
}

.td-inbox__btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.td-inbox__file-label {
  font-size: 13px;
  color: var(--accent, #2563eb);
  cursor: pointer;
  font-weight: 600;
}

.td-inbox__modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  /* Above fixed mobile nav (z-index 1000) so link / new-message / snippets modals stay usable */
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

.td-inbox__modal {
  width: min(480px, 100%);
  max-height: min(80vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--surface-1, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

/* New-email link prompt: stable height so tab switches don’t shrink the dialog */
.td-inbox__modal--compose-link {
  min-height: 456px;
  max-height: min(80vh, 560px);
}

.td-inbox__modal--compose-link .td-inbox__modal-body {
  flex: 1;
  min-height: 0;
}

.td-inbox__modal--compose-link #tdNewMsgLinkPick {
  min-height: 40px;
}

.td-inbox__modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-weight: 700;
  font-size: 16px;
}

.td-inbox__modal-body {
  padding: 14px 18px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.td-inbox__modal-lede {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary, #64748b);
}

.td-inbox__compose-anchor-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
}

.td-inbox__compose-anchor-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.td-inbox__compose-anchor-row-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.td-inbox__compose-search-label {
  margin: 0;
  margin-top: 2px;
}

.td-inbox__link-results--compose-prompt {
  margin-top: 2px;
  min-height: 200px;
  max-height: 200px;
  flex-shrink: 0;
}

.td-inbox__modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border, #e2e8f0);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.td-inbox__type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.td-inbox__type-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.td-inbox__type-tab--on {
  border-color: var(--accent, #2563eb);
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, transparent);
  color: var(--accent, #2563eb);
}

.td-inbox__link-results {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
}

.td-inbox__link-results > .td-inbox__hint {
  display: block;
  padding: 12px 10px;
  text-align: center;
}

.td-inbox__link-row {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--surface-hover, #f1f5f9);
  background: var(--surface-1, #fff);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.td-inbox__link-row:hover {
  background: var(--surface-hover, #f8fafc);
}

.td-inbox__link-row:last-child {
  border-bottom: none;
}

.td-inbox__back-mob {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--accent, #2563eb);
}

/* ─── Back-to-deal ribbon ────────────────────────────────────────────────
 * Shown at the top of the inbox conversation view when the user arrived
 * from the "Open in Inbox" button on a deal workspace. Clicking re-opens
 * the deal at the exact scroll / tab / thread they left off at. */
.td-inbox__back-to-deal {
  display: flex;
  align-items: center;
  padding: 8px 14px 0;
  background: transparent;
}
.td-inbox__back-to-deal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #4338ca;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.td-inbox__back-to-deal-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.14));
  border-color: rgba(99, 102, 241, 0.44);
  color: #312e81;
}
.td-inbox__back-to-deal-btn:active {
  transform: translateY(0.5px);
}
.td-inbox__back-to-deal-btn:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.55);
  outline-offset: 2px;
}
.td-inbox__back-to-deal-btn svg {
  flex-shrink: 0;
}
.td-inbox__back-to-deal-label {
  color: #6366f1;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.td-inbox__back-to-deal-name {
  color: #1e1b4b;
  font-weight: 700;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Phone layout + touch polish — matches app viewport contract (≤767px, body.is-mobile) */
@media (max-width: 767px) {
  .td-inbox {
    position: relative;
    min-height: 0;
  }

  .td-inbox__thread-col {
    width: 100%;
    min-width: 0;
    border-right: none;
  }

  /* Keep last threads clear of the fixed bottom nav (~60px) + home indicator */
  .td-inbox__list {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    overscroll-behavior-y: contain;
  }

  .td-inbox__toolbar {
    padding: 10px 10px 8px;
    gap: 6px;
  }

  .td-inbox__toolbar-actions {
    gap: 6px;
  }

  .td-inbox__icon-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    box-sizing: border-box;
  }

  .td-inbox__icon-btn--sm {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .td-inbox__btn-accent {
    height: 44px;
    padding: 0 18px;
    font-size: 14px;
  }

  .td-inbox__mailbox-bar .td-inbox__mailbox-tab {
    min-height: 40px;
    font-size: 13px;
    padding: 6px 14px;
  }

  .td-inbox__filter-bar {
    gap: 6px;
  }

  .td-inbox__chip-filter {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
  }

  .td-inbox__search {
    font-size: 16px;
    min-height: 44px;
  }

  .td-inbox__bulk-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

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

  .td-inbox__bulk-actions .td-inbox__btn-secondary--sm {
    min-height: 44px;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }

  .td-inbox__conv-col {
    position: absolute;
    inset: 0;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    /* Space for fixed bottom nav + composer actions */
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .td-inbox.td-inbox--conversation-open .td-inbox__thread-col {
    display: none;
  }

  .td-inbox.td-inbox--conversation-open .td-inbox__conv-col {
    transform: translateX(0);
  }

  .td-inbox__back-mob {
    display: flex;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
    touch-action: manipulation;
  }

  .td-inbox__message-list {
    padding: 12px 12px 16px;
    gap: 12px;
  }

  .td-inbox__msg {
    max-width: 92%;
  }

  .td-inbox__team-notes-details {
    margin: 0 10px 10px;
  }

  .td-inbox__team-notes {
    max-height: min(200px, 32vh);
  }

  .td-inbox__composer-shell {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .td-inbox__composer-panel > .td-inbox__composer-panel-summary {
    padding: 14px 52px 14px 14px;
    min-height: 52px;
  }

  .td-inbox__composer-panel-body {
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .td-inbox__composer-panel-kbd {
    display: none;
  }

  .td-inbox__composer-send-cluster .td-inbox__btn-primary {
    min-height: 48px;
    padding-left: 20px;
    padding-right: 20px;
    font-size: 16px;
  }

  .td-inbox__dropdown button {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 15px;
  }

  /* iOS: 16px+ on fields avoids focus-zoom that hides the composer */
  .td-inbox input,
  .td-inbox textarea,
  .td-inbox select {
    font-size: 16px !important;
  }

  .td-inbox__thread {
    touch-action: manipulation;
  }

  .td-inbox__thread-body {
    padding: 14px 12px 14px 8px;
  }

  .td-inbox__row-check {
    padding-left: 10px;
    padding-right: 6px;
  }

  .td-inbox__row-check-input {
    width: 20px;
    height: 20px;
  }

  .td-inbox__wait-btn,
  .td-inbox__conv-wait .td-inbox__btn-secondary--sm {
    min-height: 44px;
    padding: 10px 12px;
  }

  .td-inbox__modal-backdrop {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .td-inbox__modal-backdrop .td-inbox__modal {
    width: 100%;
    max-width: 100%;
    border-radius: 14px 14px 0 0;
    max-height: min(88dvh, 90vh);
    margin: 0;
  }

  .td-inbox__modal-backdrop .td-inbox__modal--compose-link {
    min-height: min(62dvh, 420px);
  }

  .td-inbox__link-results--compose-prompt {
    min-height: 180px;
    max-height: 180px;
  }
}

/* Record-scoped email embed (contact / project / invoice) */
.td-record-email {
  padding: 4px 0 16px;
}
.td-record-email__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 12px;
}
.td-record-email__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}
.td-record-email__sub {
  margin: 0;
  flex: 1 1 200px;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  line-height: 1.4;
}
.td-record-email__inbox-btn {
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary, #0f172a);
}
.td-record-email__inbox-btn:hover {
  border-color: var(--accent, #2563eb);
  color: var(--accent, #2563eb);
}
.td-record-email__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  row-gap: 12px;
  max-height: 320px;
  overflow-y: auto;
  /* Avoid flex children collapsing/overlapping when nested in tab layouts */
  align-items: stretch;
  min-height: 0;
}

/* Inline thread + conversation (record Email tab) */
.td-record-email__split {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  align-items: stretch;
}
@media (min-width: 900px) {
  .td-record-email__split:has(.td-record-email__conv-col:not([hidden])) {
    grid-template-columns: minmax(260px, 400px) minmax(0, 1fr);
  }
}
@media (max-width: 899px) {
  .td-record-email__split:has(.td-record-email__conv-col:not([hidden])) {
    grid-template-columns: 1fr;
  }
}
.td-record-email__list-col {
  min-width: 0;
}
.td-record-email__conv-col {
  min-width: 0;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface-1, #fff);
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 560px);
}
.td-record-email__conv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  flex-shrink: 0;
}
.td-record-email__conv-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.td-record-email__conv-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary, #64748b);
  padding: 4px 8px;
  border-radius: 6px;
}
.td-record-email__conv-close:hover {
  background: var(--surface-2, #f1f5f9);
  color: var(--text-primary, #0f172a);
}
.td-record-email__thread-mount {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  padding: 0 2px 8px;
}
.td-record-email__thread-inner {
  padding: 0 10px 12px;
}
.td-record-email__thread-head {
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin-bottom: 8px;
}
.td-record-email__thread-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.td-record-email__thread-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  line-height: 1.3;
  flex: 1 1 200px;
}
.td-record-email__thread-actions {
  flex-shrink: 0;
}
.td-record-email__thread-btn {
  border: 1px solid var(--accent, #2563eb);
  background: var(--accent, #2563eb);
  color: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.td-record-email__thread-btn:hover {
  filter: brightness(1.05);
}
.td-record-email__thread-participants {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  line-height: 1.35;
  word-break: break-word;
}
.td-record-email__thread-msgs {
  max-height: none;
}
.td-record-email__row.is-active {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #2563eb) 35%, transparent);
}

.td-record-email__row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  width: 100%;
  flex-shrink: 0;
  padding: 13px 14px 14px;
  box-sizing: border-box;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--surface-1, #fff);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.td-record-email__row:hover {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}
.td-record-email__row-icon {
  font-size: 16px;
  line-height: 1.2;
}
.td-record-email__row-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.td-record-email__row-subj {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-primary, #0f172a);
}
.td-record-email__row-subj-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.td-record-email__unread-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}
.td-record-email__row.is-active .td-record-email__unread-badge {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
}
.td-record-email__row-meta {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
  /* Reserve two line boxes — nested flex + -webkit-box can under-report height and paint over the next row */
  min-height: calc(1.5em * 2 + 3px);
  /* Extra room so descenders / last line aren’t clipped by line-box + clamp */
  padding-bottom: 3px;
  word-break: break-word;
}
.td-record-email__empty,
.td-record-email__err {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  padding: 12px 0;
}
.td-record-email__err {
  color: #b91c1c;
}

.td-inbox__search-hint {
  margin: 6px 4px 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-secondary, #64748b);
}

.td-inbox__composer-send-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.td-inbox__kbd-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary, #94a3b8);
  user-select: none;
}

.td-inbox__kbd-hint--modal {
  margin: 0 0 10px 0;
  width: 100%;
}

.td-inbox__modal-footer--stack {
  flex-direction: column;
  align-items: stretch;
}

.td-inbox__modal-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Record context card (thread header) */
.td-inbox__record-summary-mount {
  margin-top: 4px;
  width: 100%;
}

/* Slightly smaller menu control so the title row stays compact */
.td-inbox__conv-header .td-inbox__icon-btn {
  width: 32px;
  height: 32px;
}

.td-inbox__conv-wait .td-inbox__btn-secondary--sm {
  padding: 4px 10px;
  font-size: 11px;
  line-height: 1.2;
}

/* Linked deal — closing context (deal-linked threads), collapsed by default */
.td-inbox__deal-close-wrap {
  margin-top: 6px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 22%, var(--border, #e2e8f0));
  background: var(--surface-1, #fff);
  overflow: hidden;
}
.td-inbox__deal-close-wrap[hidden] {
  display: none !important;
}
.td-inbox__deal-close-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 36px 10px 12px;
  position: relative;
  user-select: none;
}
.td-inbox__deal-close-summary::-webkit-details-marker {
  display: none;
}
.td-inbox__deal-close-summary::after {
  content: "▸";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-tertiary, #94a3b8);
  font-weight: 700;
}
.td-inbox__deal-close-wrap[open] > .td-inbox__deal-close-summary::after {
  content: "▾";
}
.td-inbox__deal-close-summary__eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  margin-bottom: 4px;
}
.td-inbox__deal-close-summary__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
}
.td-inbox__deal-close-summary__text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  line-height: 1.35;
  min-width: 0;
  flex: 1 1 140px;
}
.td-inbox__deal-close-summary__hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #2563eb);
  flex-shrink: 0;
}
.td-inbox__deal-close--in-details {
  margin-top: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--accent, #2563eb) 14%, var(--border, #e2e8f0));
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 8%, var(--surface-1, #fff)), var(--surface-1, #fff));
}

/* Linked deal — full panel body (inside expanded details) */
.td-inbox__deal-close {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 22%, var(--border, #e2e8f0));
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 8%, var(--surface-1, #fff)), var(--surface-1, #fff));
}
.td-inbox__deal-close-head {
  margin-bottom: 8px;
}
.td-inbox__deal-close-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  margin-bottom: 4px;
}
.td-inbox__deal-close-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
  letter-spacing: -0.02em;
}
.td-inbox__deal-close-kv {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
  margin: 0 0 10px;
  padding: 0;
}
.td-inbox__deal-close-kv > div {
  margin: 0;
}
.td-inbox__deal-close-kv dt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #64748b);
  margin: 0 0 2px;
}
.td-inbox__deal-close-kv dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
}
.td-inbox__deal-close-tasks-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary, #64748b);
}
.td-inbox__deal-close-tasklist {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary, #334155);
}
.td-inbox__deal-close-tasklist--empty {
  list-style: none;
  padding-left: 0;
  color: var(--text-secondary, #64748b);
  font-style: italic;
}
.td-inbox__deal-close-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.td-inbox__deal-close-loading,
.td-inbox__deal-close-err {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}
.td-inbox__deal-close-err {
  color: #b91c1c;
}
@media (max-width: 520px) {
  .td-inbox__deal-close-kv {
    grid-template-columns: 1fr;
  }
}

.td-inbox__record-card {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  background: var(--surface-1, #fff);
  overflow: hidden;
}

.td-inbox__record-card--loading,
.td-inbox__record-card--empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
}

.td-inbox__record-card--loading {
  color: var(--text-tertiary, #94a3b8);
}

.td-inbox__record-summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  padding: 3px 52px 4px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 1px;
  align-items: center;
  background: linear-gradient(180deg, var(--surface-1, #fff) 0%, var(--surface-2, #f8fafc) 100%);
}

.td-inbox__record-summary::-webkit-details-marker {
  display: none;
}

.td-inbox__record-summary::after {
  content: "▾";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  color: var(--text-tertiary, #64748b);
  font-size: 36px;
}

.td-inbox__record-card:not([open]) .td-inbox__record-summary::after {
  content: "▸";
}

.td-inbox__record-summary-eyebrow {
  grid-column: 1 / -1;
  grid-row: 1;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent, #2563eb);
}

.td-inbox__record-summary-title {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary, #0f172a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Only eyebrow + title (no linked email): use full width */
.td-inbox__record-summary-title:last-child {
  grid-column: 1 / -1;
}

.td-inbox__record-summary-sub {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-secondary, #64748b);
  text-align: right;
  justify-self: end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-inbox__record-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border-light, #f1f5f9);
}

.td-inbox__record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 14px;
  padding-top: 12px;
}

.td-inbox__record-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.td-inbox__record-k {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary, #94a3b8);
}

.td-inbox__record-v {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
  line-height: 1.3;
  word-break: break-word;
}

.td-inbox__record-next {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2, #f1f5f9);
  border: 1px dashed var(--border, #e2e8f0);
}

.td-inbox__record-next--none {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  font-style: italic;
}

.td-inbox__record-next-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #94a3b8);
  margin-bottom: 4px;
}

.td-inbox__record-next-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #0f172a);
}

.td-inbox__record-next-due {
  display: block;
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}

.td-inbox__record-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.td-inbox__btn-secondary--sm {
  padding: 6px 12px;
  font-size: 12px;
}

.td-inbox__text-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent, #2563eb);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.td-inbox__textarea-autogrow {
  resize: none;
  overflow-y: auto;
  min-height: 96px;
  max-height: 300px;
  line-height: 1.45;
}

@supports (field-sizing: content) {
  .td-inbox__textarea-autogrow,
  #tdNewMsgBody.td-inbox__textarea {
    field-sizing: content;
  }
}

/* --- Small-team inbox: bulk, follow-up, team notes, snippets --- */

.td-inbox__bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: color-mix(in srgb, var(--accent, #2563eb) 6%, var(--surface-1, #fff));
}

.td-inbox__bulk-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.td-inbox__bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.td-inbox__filters--followup {
  margin-top: 2px;
}

.td-inbox__row-check {
  flex-shrink: 0;
  padding: 0 4px 0 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.td-inbox__row-check-input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #2563eb);
}

.td-inbox__pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.td-inbox__pill--us {
  background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
  color: var(--accent, #2563eb);
}

.td-inbox__pill--them {
  background: var(--surface-2, #e2e8f0);
  color: var(--text-secondary, #64748b);
}

.td-inbox__pill--stale {
  background: color-mix(in srgb, #f97316 18%, transparent);
  color: #c2410c;
}

.td-inbox__conv-wait {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 2px 0 4px;
  border-bottom: 1px solid var(--border-light, #f1f5f9);
  margin-bottom: 4px;
}

.td-inbox__conv-wait .td-inbox__hint {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary, #64748b);
  flex-shrink: 0;
}

.td-inbox__wait-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.td-inbox__wait-btn {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
}

.td-inbox__wait-btn:hover {
  border-color: var(--border-strong, #cbd5e1);
  color: var(--text-primary, #0f172a);
}

.td-inbox__wait-btn--on {
  border-color: color-mix(in srgb, var(--accent, #2563eb) 45%, var(--border, #e2e8f0));
  background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--surface-1, #fff));
  color: var(--accent, #2563eb);
}

.td-inbox__wait-btn--ghost {
  border-style: dashed;
}

/* Team notes — collapsed by default so the message thread stays visible */
.td-inbox__team-notes-details {
  margin: 0 16px 12px;
  border-radius: var(--td-inbox-radius, 10px);
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface-1, #fff);
  overflow: hidden;
}
.td-inbox__team-notes-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 36px 10px 14px;
  position: relative;
  user-select: none;
}
.td-inbox__team-notes-summary::-webkit-details-marker {
  display: none;
}
.td-inbox__team-notes-summary::after {
  content: "▸";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-tertiary, #94a3b8);
  font-weight: 700;
}
.td-inbox__team-notes-details[open] > .td-inbox__team-notes-summary::after {
  content: "▾";
}
.td-inbox__team-notes-summary__title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}
.td-inbox__team-notes-summary__hint {
  display: block;
  font-size: 11px;
  color: var(--text-secondary, #64748b);
  margin-top: 2px;
}

.td-inbox__team-notes {
  margin: 0;
  padding: 10px 14px 12px;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border-light, #f1f5f9);
  background: transparent;
  max-height: 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.td-inbox__team-notes-head {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.td-inbox__team-notes-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}

.td-inbox__team-notes-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-secondary, #64748b);
}

.td-inbox__team-notes-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.td-inbox__team-notes-empty {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
}

.td-inbox__team-note {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
}

.td-inbox__team-note-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-bottom: 4px;
}

.td-inbox__team-note-body {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.td-inbox__mention {
  font-weight: 700;
  color: var(--accent, #2563eb);
}

.td-inbox__team-notes-compose {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.td-inbox__snippet-list > .td-inbox__hint {
  padding: 14px 8px;
  text-align: center;
}

.td-inbox__snippet-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.td-inbox__snippet-row:last-child {
  border-bottom: none;
}

.td-inbox__snippet-preview {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}

.td-inbox__snippet-add {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.td-inbox__snippets-body {
  max-height: 52vh;
  overflow: auto;
}

/* Embed: context type chip on merged invoice list */
.td-record-email__ctx-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2, #e2e8f0);
  color: var(--text-secondary, #64748b);
  vertical-align: middle;
}
