/* Threads Leadflow L125: one calm operational shell. */
/* WHY: this single external file prevents the CRM template, mobile shell, and
   desktop shell from drifting into separate visual systems again. */
:root {
  --lf-canvas: #f7f7f5;
  --lf-surface: #ffffff;
  --lf-surface-raised: #fcfcfb;
  --lf-ink: #111827;
  --lf-ink-muted: #4b5563;
  --lf-ink-quiet: #6b7280;
  --lf-border: #d1d5db;
  --lf-border-strong: #111827;
  --lf-link: #1d4ed8;
  --lf-confirmed: #166534;
  --lf-confirmed-bg: #dcfce7;
  --lf-attention: #92400e;
  --lf-attention-bg: #fef3c7;
  --lf-failure: #991b1b;
  --lf-failure-bg: #fee2e2;
  --lf-focus: #2563eb;
  --lf-space-1: .25rem;
  --lf-space-2: .5rem;
  --lf-space-3: .75rem;
  --lf-space-4: 1rem;
  --lf-space-6: 1.5rem;
  --lf-space-8: 2rem;
  --lf-radius-control: .5rem;
  --lf-radius-surface: .75rem;
  --lf-nav-mobile-height: 4.25rem;
  --lf-rail-width: 12.5rem;
  --lf-topbar-height: 4rem;
  --lf-press-rim: 0 .22rem 0 #030712;
}

html, body { max-width: 100%; overflow-x: hidden; }
body { font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', 'Segoe UI', system-ui, sans-serif; }
.glass { backdrop-filter: blur(20px); background: rgba(255,255,255,0.8); }
.char-count { transition: color 0.2s; }
.char-count.warning { color: #f59e0b; }
.char-count.danger { color: #ef4444; }

.lead-detail[open] summary { border-bottom: 1px solid #e5e7eb; }
.lead-detail summary::-webkit-details-marker,
.flow-detail summary::-webkit-details-marker { display: none; }
.lead-detail summary,
.flow-detail summary { list-style: none; }
/* WHY: phase-label pills replace fragile absolute step numbers. Step 5 is
   conditionally hidden, so hardcoded 1..6 rendered a visible "1,2,3,4,6" gap
   that looked broken. Labels carry the phase without depending on a contiguous
   count, and auto-width lets a short phase word fit the pill. */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.65rem;
    padding: 0 .6rem;
    border-radius: 9999px;
    background: #111827;
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
    flex: 0 0 auto;
}
.mobile-action {
    min-height: 3.25rem;
    font-size: 1rem;
    touch-action: manipulation;
}
[data-threads-connect-nav].is-loading {
    opacity: .82;
    pointer-events: none;
}
.angle-button {
    min-height: 4.5rem;
    text-align: left;
}
.angle-button.is-active {
    border-color: #111827;
    background: #f9fafb;
    box-shadow: inset 0 0 0 1px #111827;
}
.tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.5rem;
    min-height: 1.9rem;
    border-radius: 9999px;
    padding: .25rem .65rem;
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}
.tier-hot { background: #dcfce7; color: #166534; }
.tier-review { background: #fef9c3; color: #854d0e; }
.tier-save { background: #dbeafe; color: #1d4ed8; }
.tier-skip { background: #f3f4f6; color: #4b5563; }
.tier-risk { background: #fee2e2; color: #991b1b; }
.sender-gate {
    border-left: 5px solid #111827;
}
.sender-gate.is-ready {
    border-left-color: #16a34a;
}
.sender-status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    border-radius: 9999px;
    padding: .35rem .75rem;
    background: #f3f4f6;
    color: #374151;
    font-size: .875rem;
    font-weight: 700;
}
.sender-status-pill.is-ready {
    background: #dcfce7;
    color: #166534;
}
.sender-status-pill.is-blocked {
    background: #fee2e2;
    color: #991b1b;
}
.mobile-action:disabled {
    opacity: .48;
    cursor: not-allowed;
}
.mobile-action.is-busy {
    opacity: .78;
    cursor: progress;
}
.leadflow-card {
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: .5rem;
    padding: .95rem;
    text-align: left;
    min-height: 5.4rem;
}
.leadflow-card.is-active {
    border-color: #030712;
    box-shadow: inset 0 0 0 1px #030712;
    background: #f9fafb;
}
.crm-workflow {
    border: 2px solid #111827;
    background: #ffffff;
    border-radius: .75rem;
    overflow: hidden;
}
.crm-workflow-header {
    background: #111827;
    color: #ffffff;
}
.crm-workflow .step-badge {
    background: #ffffff;
    color: #111827;
}
.workflow-step {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: .65rem;
    padding: .9rem;
}
.workflow-step.is-primary {
    border-color: #111827;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px #111827;
}
.workflow-chip,
.category-chip {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    border-radius: 9999px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    padding: .25rem .65rem;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
}
.workflow-chip.is-strong {
    background: #111827;
    border-color: #111827;
    color: #ffffff;
}
.workflow-chip.is-safe {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}
.workflow-chip.is-warn {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}
.category-chip {
    justify-content: space-between;
    gap: .4rem;
    width: 100%;
    min-height: 2.35rem;
}
.category-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: .5rem;
}
.workflow-proof-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    border-radius: .5rem;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    padding: .55rem .75rem;
    font-size: .875rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.leadflow-field {
    min-height: 3.25rem;
    font-size: 1rem;
}
.lead-row-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.35rem;
}
.lead-row-meta {
    font-size: .875rem;
    line-height: 1.25rem;
}
.lead-snippet {
    font-size: .95rem;
    line-height: 1.45rem;
    color: #374151;
    overflow-wrap: anywhere;
}
.lead-actions button,
.lead-actions a {
    min-height: 3rem;
    font-size: .95rem;
}
.lead-detail summary {
    min-height: 5.5rem;
    position: relative;
    z-index: 1;
}
.lead-detail > summary * {
    pointer-events: none;
}
.lead-actions {
    position: relative;
    z-index: 2;
}
.advanced-muted {
    color: #6b7280;
}
.agent-status-card {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: .5rem;
    padding: 1rem;
}
.agent-status-card.is-active {
    border-color: #111827;
    background: #f8fafc;
}
.agent-spinner {
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 9999px;
    border: 3px solid #d1d5db;
    border-top-color: #111827;
    animation: agent-spin .75s linear infinite;
    display: none;
    flex: 0 0 auto;
}
.agent-spinner.is-active {
    display: inline-block;
}
.scanner-live-dot {
    width: .7rem;
    height: .7rem;
    border-radius: 9999px;
    background: #16a34a;
    box-shadow: 0 0 0 0 rgba(22, 163, 74, .45);
    animation: scanner-pulse 1.15s ease-out infinite;
    flex: 0 0 auto;
}
.scanner-live-dot.is-paused {
    background: #9ca3af;
    box-shadow: none;
    animation: none;
}
@keyframes scanner-pulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
    70% { box-shadow: 0 0 0 .45rem rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
.agent-progress-track {
    height: .55rem;
    overflow: hidden;
    border-radius: 9999px;
    background: #e5e7eb;
}
.agent-progress-bar {
    height: 100%;
    width: var(--lf-progress, 0%);
    border-radius: inherit;
    background: #111827;
    transition: width .25s ease;
}
.setup-action-hero {
    border-left: 5px solid #111827;
}
.setup-primary-action {
    min-height: 3.5rem;
}
.setup-preview-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    background: #f9fafb;
    padding: .85rem;
}
.setup-preview-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 9999px;
    background: #e5e7eb;
    color: #4b5563;
    font-size: .8rem;
    font-weight: 800;
    flex: 0 0 auto;
}
@keyframes agent-spin {
    to { transform: rotate(360deg); }
}
@media (max-width: 640px) {
    .leadflow-page > .bg-white.border {
        border-left-width: 0;
        border-right-width: 0;
        border-radius: 0;
    }
    .leadflow-page {
        gap: .85rem;
    }
    .workflow-step {
        padding: .8rem;
    }
    .workflow-chip,
    .category-chip {
        font-size: .78rem;
    }
    .workflow-proof-link {
        width: 100%;
    }
}


/* L125 adaptive shell */
.lf-body {
  background: var(--lf-canvas);
  color: var(--lf-ink);
  min-width: 20rem;
  padding-bottom: calc(var(--lf-nav-mobile-height) + env(safe-area-inset-bottom));
  scroll-padding-top: calc(var(--lf-topbar-height) + var(--lf-space-4));
  scroll-padding-bottom: calc(var(--lf-nav-mobile-height) + env(safe-area-inset-bottom) + var(--lf-space-4));
}

.lf-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--lf-topbar-height);
  border-bottom: 1px solid var(--lf-border);
  background: rgba(255, 255, 255, .97);
}

.lf-header-inner {
  display: flex;
  min-height: var(--lf-topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: var(--lf-space-3);
  padding: var(--lf-space-2) var(--lf-space-4);
}

.lf-brand {
  color: var(--lf-ink);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -.015em;
  text-decoration: none;
}

.lf-utility-nav {
  display: flex;
  align-items: center;
  gap: var(--lf-space-2);
  color: var(--lf-ink-muted);
  font-size: .875rem;
}

.lf-account-menu {
  position: relative;
}

.lf-account-menu > summary {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface);
  padding: .55rem .75rem;
  color: var(--lf-ink);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

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

.lf-account-popover {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  z-index: 80;
  display: grid;
  width: min(16rem, calc(100vw - 2rem));
  gap: .25rem;
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-surface);
  background: var(--lf-surface);
  padding: .5rem;
  box-shadow: 0 .75rem 1.75rem rgba(17, 24, 39, .14);
}

.lf-account-popover a {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  border-radius: var(--lf-radius-control);
  padding: .5rem .75rem;
  color: var(--lf-ink);
  font-weight: 650;
  text-decoration: none;
}

.lf-account-menu-label {
  margin: .35rem .75rem 0;
  color: var(--lf-ink-quiet);
  font-size: .6875rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lf-account-popover a:hover {
  background: var(--lf-canvas);
}

.lf-primary-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .25rem;
  min-height: calc(var(--lf-nav-mobile-height) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--lf-border);
  background: rgba(255, 255, 255, .98);
  padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
}

.lf-nav-link {
  position: relative;
  display: inline-flex;
  min-width: 0;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid transparent;
  border-radius: var(--lf-radius-control);
  color: var(--lf-ink-muted);
  font-size: .8125rem;
  font-weight: 750;
  text-decoration: none;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.lf-nav-link[aria-current="page"] {
  border-color: var(--lf-border);
  background: var(--lf-canvas);
  color: var(--lf-ink);
}

.lf-nav-count {
  display: inline-flex;
  min-width: 1.25rem;
  min-height: 1.25rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--lf-ink);
  padding: 0 .3rem;
  color: white;
  font-size: .6875rem;
  line-height: 1;
}

.lf-nav-count[hidden] {
  display: none;
}

.lf-main {
  width: 100%;
  max-width: none;
  padding: .75rem .5rem calc(var(--lf-nav-mobile-height) + env(safe-area-inset-bottom) + 1rem);
}

.lf-app {
  width: 100%;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

.lf-shell-notice {
  max-width: 76rem;
  margin: 0 auto var(--lf-space-3);
  border: 1px solid #bfdbfe;
  border-radius: var(--lf-radius-control);
  background: #eff6ff;
  padding: .75rem 1rem;
  color: var(--lf-link);
  font-weight: 700;
}

.lf-anchor {
  display: block;
  scroll-margin-top: calc(var(--lf-topbar-height) + var(--lf-space-4));
}

[data-lf-panel][hidden],
.lf-compat-surface {
  display: none !important;
}

.lf-operating-overview {
  border-left-color: var(--lf-ink);
  box-shadow: 0 1px 0 rgba(17, 24, 39, .04);
}

/* Advanced is reachable from Account, but a closed expert panel must not read
   as a fourth normal destination in the main operational flow. */
.lf-advanced-tools:not(:target):not([open]) {
  display: none;
}

.lf-destination-panel {
  width: 100%;
  max-width: 76rem;
  margin-inline: auto;
}

.lf-destination-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--lf-space-3);
  margin-bottom: var(--lf-space-3);
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-surface);
  background: var(--lf-surface);
  padding: var(--lf-space-4);
  box-shadow: 0 1px 0 rgba(17, 24, 39, .05);
}

.lf-destination-header h2 {
  margin: .1rem 0 .25rem;
  color: var(--lf-ink);
  font-size: clamp(1.25rem, 2.5vw, 1.65rem);
  line-height: 1.2;
}

.lf-destination-header p {
  color: var(--lf-ink-muted);
}

.lf-eyebrow {
  color: var(--lf-ink-quiet) !important;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lf-message-switcher {
  display: flex;
  width: 100%;
  max-width: 76rem;
  margin: 0 auto var(--lf-space-3);
  gap: var(--lf-space-2);
}

.lf-message-filter {
  display: inline-flex;
  min-height: 2.75rem;
  flex: 1;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface);
  color: var(--lf-ink-muted);
  font-weight: 750;
}

.lf-message-filter[aria-pressed="true"] {
  border-color: var(--lf-border-strong);
  background: var(--lf-ink);
  color: white;
}

.lf-review-shell {
  background: var(--lf-surface);
}

.lf-review-rows {
  min-width: 0;
}

.lf-message-detail {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lf-message-back {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface);
  padding: .55rem .8rem;
  color: var(--lf-ink);
  font-weight: 750;
}

.lf-message-empty {
  display: none;
}

.lf-recovery-state {
  margin-bottom: var(--lf-space-3);
  border: 1px dashed var(--lf-border);
  border-radius: var(--lf-radius-surface);
  background: var(--lf-surface-raised);
  padding: var(--lf-space-6);
  color: var(--lf-ink-muted);
  text-align: center;
}

.lf-recovery-state button {
  min-height: 44px;
  margin-top: var(--lf-space-3);
  border: 1px solid var(--lf-border-strong);
  border-radius: var(--lf-radius-control);
  background: var(--lf-ink);
  padding: .65rem 1rem;
  color: white;
  font-weight: 750;
  box-shadow: var(--lf-press-rim);
}

.lf-bulk-tools {
  border: 1px solid var(--lf-border);
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface-raised);
}

.lf-bulk-tools > summary {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding: .55rem .75rem;
  cursor: pointer;
  font-weight: 700;
}

.lf-bulk-actions {
  display: grid;
  gap: var(--lf-space-2);
  border-top: 1px solid var(--lf-border);
  padding: var(--lf-space-3);
}

.lead-row-title {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
  -webkit-box-orient: initial;
}

.lead-detail[data-lf-edit-state="dirty"] {
  --lf-edit-accent: var(--lf-attention);
}

.lead-detail[data-lf-edit-state="dirty"] > summary {
  box-shadow: inset .25rem 0 0 var(--lf-edit-accent);
}

.lead-detail [data-lf-action] {
  border: 1px solid var(--lf-border) !important;
  background: var(--lf-surface) !important;
  color: var(--lf-ink) !important;
  box-shadow: none;
}

.lead-detail[data-lf-has-draft="false"] [data-lf-action="draft"],
.lead-detail[data-lf-has-draft="true"][data-lf-edit-state="clean"] [data-lf-action="queue"],
.lead-detail[data-lf-edit-state="dirty"] [data-lf-action="save"] {
  border-color: var(--lf-ink) !important;
  background: var(--lf-ink) !important;
  color: white !important;
  box-shadow: var(--lf-press-rim);
}

.lead-detail[data-lf-edit-state="dirty"] [data-lf-action="queue"] {
  opacity: .45;
  cursor: not-allowed;
}

.lead-detail [data-lf-action="send"] {
  border-color: #fecaca !important;
  background: var(--lf-surface) !important;
  color: var(--lf-failure) !important;
}

.lead-detail [data-lf-action="thread"] {
  border-color: #bfdbfe !important;
  color: var(--lf-link) !important;
}

.lead-detail [data-lf-action]:active,
.setup-primary-action:active,
.lf-message-filter:active {
  transform: translateY(.15rem);
  box-shadow: none;
  transition-duration: 34ms;
}

.lf-status-line {
  min-height: 1.5rem;
}

#autoReplyControlCard {
  max-width: 64rem;
  margin-inline: auto;
}

.lf-app[data-lf-message-view="review"] #autoReplyControlCard {
  display: none !important;
}

.lf-activity-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.lf-state-chip {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  border: 1px solid var(--lf-border);
  border-radius: 999px;
  background: var(--lf-surface-raised);
  padding: .3rem .6rem;
  color: var(--lf-ink-muted);
  font-size: .75rem;
  font-weight: 700;
}

.lf-state-chip[data-state="confirmed"] {
  border-color: #bbf7d0;
  background: var(--lf-confirmed-bg);
  color: var(--lf-confirmed);
}

.lf-state-chip[data-state="requested"],
.lf-state-chip[data-state="posting"],
.lf-state-chip[data-state="verifying"] {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--lf-link);
}

.lf-state-chip[data-state="failed"],
.lf-state-chip[data-state="proof-uncertain"] {
  border-color: #fecaca;
  background: var(--lf-failure-bg);
  color: var(--lf-failure);
}

.lf-activity-panel {
  display: grid;
  gap: var(--lf-space-3);
}

.lf-activity-item {
  display: grid;
  min-width: 0;
  gap: .35rem;
  border: 1px solid var(--lf-border);
  border-left-width: .25rem;
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface);
  padding: .75rem;
}

.lf-activity-item[data-lf-activity-state="confirmed"] {
  border-left-color: var(--lf-confirmed);
}

.lf-activity-item[data-lf-activity-state="failed"],
.lf-activity-item[data-lf-activity-state="proof-uncertain"] {
  border-left-color: var(--lf-failure);
}

.lf-activity-link {
  display: inline-flex;
  min-height: 44px;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  color: var(--lf-link);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.lf-dialog {
  width: min(30rem, calc(100% - 2rem));
  max-width: 100%;
  border: 0;
  border-radius: var(--lf-radius-surface);
  background: transparent;
  padding: 0;
  color: var(--lf-ink);
}

.lf-dialog::backdrop {
  background: rgba(17, 24, 39, .55);
}

.lf-dialog-card {
  display: grid;
  gap: var(--lf-space-3);
  border: 2px solid var(--lf-border-strong);
  border-radius: var(--lf-radius-surface);
  background: var(--lf-surface);
  padding: var(--lf-space-6);
  box-shadow: 0 1.25rem 3rem rgba(17, 24, 39, .24);
}

.lf-dialog-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--lf-space-2);
}

.lf-dialog-actions button {
  min-height: 44px;
  border: 1px solid var(--lf-border-strong);
  border-radius: var(--lf-radius-control);
  background: var(--lf-surface);
  padding: .65rem 1rem;
  color: var(--lf-ink);
  font-weight: 750;
}

.lf-dialog-actions .lf-danger-action {
  border-color: #fecaca;
  background: var(--lf-failure-bg);
  color: var(--lf-failure);
}

.mobile-action,
.lf-nav-link,
.lf-message-filter,
.lf-message-back,
button,
select,
input,
textarea,
summary {
  touch-action: manipulation;
  min-height: 44px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--lf-focus);
  outline-offset: 3px;
}

textarea,
input,
select {
  font-size: 1rem;
}

h1,
h2,
h3,
p,
a,
button,
label,
summary,
textarea {
  overflow-wrap: normal;
  word-break: normal;
}

@media (max-width: 899px) {
  .leadflow-page > .bg-white.border,
  .leadflow-page > section,
  .leadflow-page > details,
  .leadflow-page > header {
    border-right-width: 0;
    border-left-width: 0;
    border-radius: 0;
  }

  .lead-detail[open] {
    position: fixed;
    top: var(--lf-topbar-height);
    right: 0;
    bottom: calc(var(--lf-nav-mobile-height) + env(safe-area-inset-bottom));
    left: 0;
    z-index: 35;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--lf-canvas);
  }

  .lead-detail[open] > summary {
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--lf-border);
    background: var(--lf-surface);
    padding-right: 9rem;
  }

  .lf-message-back:not([hidden]) {
    position: fixed;
    top: calc(var(--lf-topbar-height) + .5rem);
    right: .75rem;
    z-index: 39;
    min-height: 44px;
    background: var(--lf-surface);
    box-shadow: 0 .25rem .75rem rgba(17, 24, 39, .12);
  }

  .lead-detail[open] > .lf-message-detail {
    min-height: calc(100% - 5.5rem);
  }

  /* WHY L125 W18-B: only the visible Messages detail may own the mobile
     scroll lock. An open row hidden by a destination/filter must never freeze
     Leads or Activity. */
  body:has(#lf-messages:not([hidden]) .lead-detail[open]:not([hidden])) {
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  .lf-destination-header {
    display: block;
    border-right-width: 0;
    border-left-width: 0;
    border-radius: 0;
  }

  .lf-message-switcher,
  .lf-dialog-actions {
    grid-template-columns: 1fr;
  }

  .lf-message-switcher {
    display: grid;
  }
}

@media (min-width: 900px) {
  .lf-body {
    padding-bottom: 0;
    scroll-padding-bottom: var(--lf-space-6);
  }

  .lf-primary-nav {
    top: var(--lf-topbar-height);
    right: auto;
    bottom: 0;
    width: var(--lf-rail-width);
    min-height: 0;
    grid-template-columns: 1fr;
    align-content: start;
    gap: var(--lf-space-2);
    border-top: 0;
    border-right: 1px solid var(--lf-border);
    padding: var(--lf-space-4);
  }

  .lf-nav-link {
    min-height: 3rem;
    justify-content: flex-start;
    padding: .65rem .75rem;
    font-size: .9375rem;
  }

  .lf-main {
    width: calc(100% - var(--lf-rail-width));
    margin-left: var(--lf-rail-width);
    padding: var(--lf-space-4);
  }

  .lf-review-shell {
    width: 23rem;
    min-height: calc(100svh - 7rem);
    overflow: visible !important;
  }

  .lf-review-header {
    position: sticky;
    top: calc(var(--lf-topbar-height) + var(--lf-space-4));
    z-index: 3;
    background: var(--lf-surface);
  }

  .lf-review-rows {
    max-height: calc(100svh - 18rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .lead-detail {
    width: 100%;
  }

  .lead-detail[open] > .lf-message-detail {
    position: fixed;
    top: calc(var(--lf-topbar-height) + var(--lf-space-4));
    right: var(--lf-space-4);
    bottom: var(--lf-space-4);
    left: calc(var(--lf-rail-width) + 25rem);
    z-index: 10;
    overflow-y: auto;
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-surface);
    background: var(--lf-surface-raised);
    box-shadow: 0 .75rem 2rem rgba(17, 24, 39, .08);
  }

  .lf-message-back {
    display: none;
  }

  .lf-message-empty {
    position: fixed;
    top: calc(var(--lf-topbar-height) + var(--lf-space-4));
    right: var(--lf-space-4);
    bottom: var(--lf-space-4);
    left: calc(var(--lf-rail-width) + 25rem);
    display: grid;
    place-items: center;
    border: 1px dashed var(--lf-border);
    border-radius: var(--lf-radius-surface);
    background: var(--lf-surface-raised);
    padding: var(--lf-space-8);
    color: var(--lf-ink-muted);
    text-align: center;
  }

  body:has(#lf-messages:not([hidden]) .lead-detail[open]:not([hidden])) .lf-message-empty {
    display: none;
  }

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

.native-threads-login-panel {
  width: 100%;
  overflow-x: hidden;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.native-threads-login-form {
  display: grid;
  gap: .875rem;
  width: 100%;
  min-width: 0;
}

.native-threads-login-field {
  display: grid;
  gap: .375rem;
  min-width: 0;
}

.native-threads-login-field label {
  color: #172554;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.4;
}

.native-threads-login-input {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  border: 1px solid #93c5fd;
  border-radius: .375rem;
  background: #fff;
  padding: .75rem .875rem;
  color: #111827;
  font-size: 16px;
  line-height: 1.35;
}

.native-threads-login-input:focus-visible {
  border-color: #2563eb;
  outline: 3px solid rgba(37, 99, 235, .24);
  outline-offset: 1px;
}

.native-threads-login-input:disabled {
  background: #e5e7eb;
  color: #6b7280;
}

.native-threads-login-primary {
  display: inline-flex;
  min-height: 44px;
  width: 100%;
  align-items: center;
  justify-content: center;
  border: 1px solid #1d4ed8;
  border-radius: .375rem;
  background: #2563eb;
  padding: .75rem 1rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.native-threads-login-primary:disabled {
  cursor: wait;
  opacity: .72;
}

.native-threads-login-state {
  display: flex;
  min-height: 52px;
  align-items: center;
  color: #172554;
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.45;
}

.native-threads-login-disclosure {
  margin-top: .75rem;
  color: #374151;
  font-size: .75rem;
  line-height: 1.5;
}

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

@media print {
  .lf-primary-nav,
  .lf-topbar,
  .lf-message-back {
    display: none !important;
  }

  .lf-main {
    width: 100%;
    margin: 0;
  }
}
