/* Unified CRM directory, profile, and relationship components */
.crm-directory-page,
.crm-profile-page {
    gap: 24px;
}

.crm-primary-action {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}

.crm-primary-action > span {
    font-size: 1.1rem;
    line-height: 1;
}

.crm-directory-surface {
    display: grid;
    gap: 20px;
    overflow: hidden;
}

.crm-directory-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 20px;
}

.crm-directory-count {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    border-left: 1px solid var(--color-border);
    padding-left: 18px;
}

.crm-directory-count > span:last-child {
    display: grid;
    line-height: 1.05;
}

.crm-directory-count strong {
    color: var(--color-text-primary);
    font-size: 1.125rem;
}

.crm-directory-count small {
    color: var(--color-text-tertiary);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.crm-record-table__head,
.crm-record-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) minmax(180px, 1fr) minmax(230px, 1.2fr) 32px;
    align-items: center;
    gap: 18px;
}

.crm-record-table__head {
    color: var(--color-text-tertiary);
    padding: 0 16px 10px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.crm-record-row {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: 13px 16px;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.crm-record-row:hover {
    border-color: rgba(239, 111, 42, 0.48);
    background: rgba(239, 111, 42, 0.035);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    transform: translateY(-1px);
}

.crm-record-identity {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.crm-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.72rem;
}

.crm-record-cell {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.crm-record-cell strong {
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-record-cell small {
    overflow: hidden;
    color: var(--color-text-tertiary);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-mobile-label {
    display: none;
}

.crm-record-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-text-tertiary);
    font-size: 0.95rem;
    transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.crm-record-row:hover .crm-record-arrow,
.crm-company-card:hover .crm-record-arrow,
.crm-contact-card:hover .crm-record-arrow,
.crm-related-card:hover .crm-record-arrow,
.crm-profile-company-card:hover .crm-record-arrow {
    border-color: rgba(239, 111, 42, 0.42);
    background: rgba(239, 111, 42, 0.1);
    color: #ef6f2a;
}

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

.crm-company-card {
    display: grid;
    gap: 18px;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: 18px;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.crm-company-card:hover {
    border-color: rgba(239, 111, 42, 0.48);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.crm-company-card__head,
.crm-profile-company-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.crm-company-avatar {
    width: 48px;
    height: 48px;
    font-size: 0.78rem;
}

.crm-company-card__title {
    display: block;
    overflow: hidden;
    margin-bottom: 4px;
    font-size: 1rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-company-card__details {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(76px, 0.5fr) minmax(0, 1.5fr);
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}

.crm-company-card__details > span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.crm-company-card__details small,
.crm-profile-company-card small,
.crm-company-detail-list small {
    color: var(--color-text-tertiary);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.crm-company-card__details strong {
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-directory-empty {
    min-height: 280px;
}

.crm-profile-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-top: 3px solid #ef6f2a;
}

.crm-profile-identity {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.crm-profile-avatar {
    width: 68px;
    height: 68px;
    box-shadow: 0 0 0 6px rgba(239, 111, 42, 0.08);
    font-size: 1rem;
}

.crm-profile-subtitle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.crm-profile-subtitle a {
    color: #d85d1f;
    font-weight: 650;
}

.crm-profile-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-profile-layout {
    display: grid;
    align-items: start;
    gap: 24px;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.7fr);
}

.crm-profile-main,
.crm-profile-aside,
.crm-profile-section {
    display: grid;
    gap: 20px;
}

.crm-profile-aside {
    position: sticky;
    top: 80px;
}

.crm-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

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

.crm-detail-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg-subtle);
    padding: 14px;
}

.crm-detail-item > span:last-child {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.crm-detail-item small,
.crm-related-card small,
.crm-contact-card small,
.crm-inline-empty small {
    overflow: hidden;
    color: var(--color-text-tertiary);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-detail-item strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-related-list {
    display: grid;
    gap: 9px;
}

.crm-related-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: 13px 14px;
    transition: border-color 160ms ease, background 160ms ease;
}

.crm-related-card:hover {
    border-color: rgba(239, 111, 42, 0.42);
    background: rgba(239, 111, 42, 0.035);
}

.crm-related-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(239, 111, 42, 0.1);
    color: #ef6f2a;
}

.crm-related-card > span:nth-child(2) {
    display: grid;
    gap: 2px;
}

.crm-related-card__value {
    color: var(--color-text-primary);
    font-size: 0.82rem;
    font-weight: 750;
    white-space: nowrap;
}

.crm-inline-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 120px;
    border: 1px dashed var(--color-border-strong);
    border-radius: 14px;
    background: var(--color-bg-subtle);
    color: var(--color-text-primary);
    padding: 20px;
    text-align: left;
}

.crm-inline-empty > span:last-child {
    display: grid;
    gap: 3px;
}

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

.crm-contact-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: 13px;
    transition: border-color 160ms ease, background 160ms ease;
}

.crm-contact-card:hover {
    border-color: rgba(239, 111, 42, 0.42);
    background: rgba(239, 111, 42, 0.035);
}

.crm-contact-card > span:nth-child(2) {
    display: grid;
    gap: 2px;
}

.crm-contact-grid__empty {
    grid-column: 1 / -1;
}

.crm-profile-company-card {
    display: grid;
    gap: 15px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.crm-profile-company-card:hover {
    border-color: rgba(239, 111, 42, 0.45);
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.07);
    transform: translateY(-1px);
}

.crm-profile-company-card > span:last-child {
    display: grid;
    gap: 4px;
}

.crm-profile-company-card strong {
    font-size: 1rem;
}

.crm-profile-company-card > span:last-child > span {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
}

.crm-notes-card,
.crm-company-details-card {
    display: grid;
    gap: 14px;
}

.crm-company-detail-list {
    display: grid;
    gap: 0;
}

.crm-company-detail-list > div {
    display: grid;
    gap: 4px;
    border-top: 1px solid var(--color-border);
    padding: 12px 0;
}

.crm-company-detail-list strong {
    overflow-wrap: anywhere;
    color: var(--color-text-primary);
    font-size: 0.82rem;
    font-weight: 650;
}

.crm-record-audit {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--color-text-tertiary);
    padding: 0 4px;
    font-size: 0.7rem;
}

.crm-modal-shell {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
}

.crm-modal-shell.hidden {
    display: none !important;
}

.crm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(5px);
}

.crm-modal-dialog {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0;
    width: min(760px, 100%);
    max-height: min(88vh, 820px);
    overflow: hidden;
    padding: 0;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
}

.crm-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--color-border);
    padding: 22px 24px;
}

.crm-modal-title-group {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: 14px;
}

.crm-modal-icon {
    margin-top: 1px;
}

.crm-modal-form {
    display: grid;
    min-height: 0;
    overflow: hidden;
}

.crm-modal-fields {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-y: auto;
    padding: 22px 24px;
}

.crm-form-field {
    min-width: 0;
}

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

.crm-form-field label {
    display: block;
    margin-bottom: 7px;
    color: var(--color-text-primary);
    font-size: 0.78rem;
    font-weight: 650;
}

.crm-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    padding: 16px 24px;
}

.deal-crm-blocks {
    display: grid;
    gap: 9px;
}

.deal-crm-blocks__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--color-text-tertiary);
    padding: 0 2px 2px;
    font-size: 0.64rem;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.deal-crm-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 13px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    padding: 11px;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

a.deal-crm-card:hover {
    border-color: var(--deal-accent-border-light, rgba(239, 111, 42, 0.42));
    background: var(--deal-accent-surface-light, rgba(239, 111, 42, 0.06));
    transform: translateY(-1px);
}

.deal-crm-card--empty {
    border-style: dashed;
}

.deal-crm-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.66rem;
}

.deal-crm-card__label {
    display: block;
    margin-bottom: 1px;
    color: var(--color-text-tertiary);
    font-size: 0.58rem;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.deal-crm-card__title {
    display: block;
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.8rem;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-crm-card .bos-meta {
    display: block;
    overflow: hidden;
    margin-top: 1px;
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-crm-card__arrow {
    color: var(--color-text-tertiary);
    font-size: 0.9rem;
}

html[data-theme="dark"] .crm-record-row:hover,
html[data-theme="dark"] .crm-company-card:hover,
html[data-theme="dark"] .crm-related-card:hover,
html[data-theme="dark"] .crm-contact-card:hover {
    background: rgba(239, 111, 42, 0.08);
}

html[data-theme="dark"] .crm-modal-backdrop {
    background: rgba(0, 0, 0, 0.72);
}

html[data-theme="dark"] a.deal-crm-card:hover {
    border-color: var(--deal-accent-border-dark, rgba(239, 111, 42, 0.48));
    background: var(--deal-accent-surface-dark, rgba(239, 111, 42, 0.12));
}

@media (max-width: 1023px) {
    .crm-company-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-profile-layout {
        grid-template-columns: 1fr;
    }

    .crm-profile-aside {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-record-audit {
        grid-column: 1 / -1;
    }
}

@media (max-width: 799px) {
    .crm-record-table__head {
        display: none;
    }

    .crm-record-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .crm-record-cell {
        grid-column: 1 / -1;
        padding-left: 52px;
    }

    .crm-mobile-label {
        display: block;
        color: var(--color-text-tertiary);
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .crm-record-row > .crm-record-arrow {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 639px) {
    .crm-primary-action,
    .crm-profile-actions,
    .crm-profile-actions .bos-btn-ghost,
    .crm-profile-actions .bos-btn-primary {
        width: 100%;
    }

    .crm-primary-action,
    .crm-profile-actions .bos-btn-ghost,
    .crm-profile-actions .bos-btn-primary {
        justify-content: center;
    }

    .crm-directory-toolbar,
    .crm-profile-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .crm-directory-count {
        border-top: 1px solid var(--color-border);
        border-left: 0;
        padding-top: 14px;
        padding-left: 0;
    }

    .crm-company-grid,
    .crm-contact-grid,
    .crm-detail-grid,
    .crm-profile-aside,
    .crm-modal-fields {
        grid-template-columns: 1fr;
    }

    .crm-profile-identity {
        align-items: start;
    }

    .crm-profile-avatar {
        width: 56px;
        height: 56px;
    }

    .crm-profile-actions {
        display: grid;
    }

    .crm-related-card {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .crm-related-card__value {
        grid-column: 2;
    }

    .crm-related-card > .crm-record-arrow {
        grid-column: 3;
        grid-row: 1;
    }

    .crm-form-field--wide {
        grid-column: auto;
    }

    .crm-modal-shell {
        align-items: end;
        padding: 10px;
    }

    .crm-modal-dialog {
        max-height: 92vh;
        border-radius: 18px 18px 12px 12px;
    }

    .crm-modal-head,
    .crm-modal-fields {
        padding: 18px;
    }

    .crm-modal-footer {
        padding: 14px 18px;
    }
}

/* Deal workspace: fixed side rails with a fluid activity column */
.deal-detail-shell {
    --deal-panel-motion: 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

.deal-detail-panel {
    overflow: clip;
    transition:
        gap var(--deal-panel-motion),
        min-height var(--deal-panel-motion),
        padding var(--deal-panel-motion),
        box-shadow 220ms ease;
}

.deal-detail-panel-head {
    min-width: 0;
    transition:
        border-color 220ms ease,
        padding var(--deal-panel-motion);
}

.deal-detail-panel-copy {
    display: block;
    min-width: 0;
    max-width: 100%;
    opacity: 1;
    overflow: hidden;
    transform: translateX(0);
    transition:
        max-width var(--deal-panel-motion),
        opacity 180ms ease,
        transform var(--deal-panel-motion),
        visibility 0s linear;
    visibility: visible;
}

.deal-detail-panel-body {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    min-height: 0;
    opacity: 1;
    transform: translateX(0);
    transition:
        grid-template-rows var(--deal-panel-motion),
        opacity 180ms ease,
        transform var(--deal-panel-motion),
        visibility 0s linear;
    visibility: visible;
}

.deal-detail-panel-body-inner {
    display: grid;
    gap: 20px;
    min-height: 0;
    overflow: hidden;
}

.deal-panel-toggle {
    position: relative;
    transition:
        width var(--deal-panel-motion),
        min-height var(--deal-panel-motion),
        padding var(--deal-panel-motion),
        border-color 160ms ease,
        color 160ms ease,
        background 160ms ease;
}

.deal-panel-rail-name {
    position: absolute;
    width: 0;
    max-height: 0;
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    opacity: 0;
    overflow: hidden;
    text-transform: uppercase;
    visibility: hidden;
    writing-mode: vertical-rl;
    transition:
        max-height var(--deal-panel-motion),
        opacity 180ms ease,
        visibility 0s linear var(--deal-panel-motion);
}

.deal-detail-shell .deal-detail-panel.is-collapsed {
    gap: 0;
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-detail-panel-head {
    align-items: stretch;
    height: 100%;
    border-bottom-color: transparent;
    padding-bottom: 0;
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-detail-panel-head > .deal-detail-panel-copy {
    display: block;
    max-width: 0;
    opacity: 0;
    transform: translateX(-12px);
    visibility: hidden;
    transition:
        max-width var(--deal-panel-motion),
        opacity 140ms ease,
        transform var(--deal-panel-motion),
        visibility 0s linear 180ms;
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-detail-panel-body {
    display: grid;
    grid-template-rows: minmax(0, 0fr);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-12px);
    visibility: hidden;
    transition:
        grid-template-rows var(--deal-panel-motion),
        opacity 140ms ease,
        transform var(--deal-panel-motion),
        visibility 0s linear var(--deal-panel-motion);
}

.deal-detail-shell .deal-detail-panel--integrations.is-collapsed .deal-detail-panel-copy,
.deal-detail-shell .deal-detail-panel--integrations.is-collapsed .deal-detail-panel-body {
    transform: translateX(12px);
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-toggle {
    display: inline-flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    height: 100%;
    min-height: 220px;
    border-color: transparent;
    background: transparent;
    padding: 12px 8px;
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-toggle:hover {
    border-color: var(--deal-accent-border-light);
    background: var(--deal-accent-surface-light);
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-toggle [data-panel-toggle-label] {
    display: none;
}

.deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-rail-name {
    position: static;
    width: auto;
    max-height: 150px;
    opacity: 1;
    transform: rotate(180deg);
    visibility: visible;
    transition:
        max-height var(--deal-panel-motion),
        opacity 180ms ease 120ms,
        visibility 0s linear;
}

@media (min-width: 1280px) {
    .deal-detail-shell {
        --deal-properties-width: 25%;
        --deal-integrations-width: 22%;
        --deal-collapsed-width: 64px;
        grid-template-columns:
            var(--deal-properties-width)
            minmax(0, 1fr)
            var(--deal-integrations-width);
        transition: grid-template-columns var(--deal-panel-motion);
        will-change: grid-template-columns;
    }

    .deal-detail-shell.properties-collapsed {
        grid-template-columns:
            var(--deal-collapsed-width)
            minmax(0, 1fr)
            var(--deal-integrations-width);
    }

    .deal-detail-shell.integrations-collapsed {
        grid-template-columns:
            var(--deal-properties-width)
            minmax(0, 1fr)
            var(--deal-collapsed-width);
    }

    .deal-detail-shell.properties-collapsed.integrations-collapsed {
        grid-template-columns:
            var(--deal-collapsed-width)
            minmax(0, 1fr)
            var(--deal-collapsed-width);
    }

    .deal-detail-panel--properties,
    .deal-detail-panel--integrations {
        position: sticky;
        top: 80px;
        align-self: start;
        max-height: calc(100vh - 96px);
        overflow-x: clip;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }

    .deal-detail-panel--properties.is-collapsed,
    .deal-detail-panel--integrations.is-collapsed {
        height: clamp(240px, 36vh, 320px);
        min-height: 240px;
        overflow: hidden;
        padding: 12px;
    }

    .deal-detail-panel--center {
        width: 100%;
        transition: box-shadow 220ms ease;
    }

    .deal-detail-shell.is-resizing .deal-detail-panel--center {
        box-shadow: var(--app-deal-soft-panel-shadow);
    }
}

@media (max-width: 1279px) {
    .deal-detail-shell,
    .deal-detail-shell.properties-collapsed,
    .deal-detail-shell.integrations-collapsed,
    .deal-detail-shell.properties-collapsed.integrations-collapsed {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-detail-panel--properties,
    .deal-detail-panel--integrations {
        position: static;
        max-height: none;
        overflow: clip;
    }

    .deal-detail-shell .deal-detail-panel.is-collapsed {
        height: auto;
        min-height: 64px;
        padding: 12px;
    }

    .deal-detail-shell .deal-detail-panel.is-collapsed .deal-detail-panel-head {
        height: auto;
    }

    .deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-toggle {
        flex-direction: row;
        width: 100%;
        height: auto;
        min-height: 42px;
        padding: 8px 12px;
    }

    .deal-detail-shell .deal-detail-panel.is-collapsed .deal-panel-rail-name {
        max-height: none;
        transform: none;
        writing-mode: horizontal-tb;
    }
}

@media (prefers-reduced-motion: reduce) {
    .deal-detail-shell,
    .deal-detail-panel,
    .deal-detail-panel-head,
    .deal-detail-panel-copy,
    .deal-detail-panel-body,
    .deal-panel-toggle,
    .deal-panel-rail-name {
        transition-duration: 1ms !important;
    }
}

/* Deal activity stream and Outlook reading experience */
.deal-detail-panel--properties,
.deal-detail-panel--integrations,
.deal-activity-stream,
.deal-email-body {
    scrollbar-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 68%, var(--color-border-strong)) transparent;
    scrollbar-width: thin;
}

.deal-detail-panel--properties::-webkit-scrollbar,
.deal-detail-panel--integrations::-webkit-scrollbar,
.deal-activity-stream::-webkit-scrollbar,
.deal-email-body::-webkit-scrollbar {
    width: 11px;
}

.deal-detail-panel--properties::-webkit-scrollbar-track,
.deal-detail-panel--integrations::-webkit-scrollbar-track,
.deal-activity-stream::-webkit-scrollbar-track,
.deal-email-body::-webkit-scrollbar-track {
    margin-block: 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-bg-subtle) 78%, transparent);
}

.deal-detail-panel--properties::-webkit-scrollbar-thumb,
.deal-detail-panel--integrations::-webkit-scrollbar-thumb,
.deal-activity-stream::-webkit-scrollbar-thumb,
.deal-email-body::-webkit-scrollbar-thumb {
    min-height: 48px;
    border: 3px solid transparent;
    border-radius: 999px;
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 88%, white),
            var(--deal-accent-color, #ef6f2a)
        ) padding-box;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 45%, transparent);
}

.deal-detail-panel--properties::-webkit-scrollbar-thumb:hover,
.deal-detail-panel--integrations::-webkit-scrollbar-thumb:hover,
.deal-activity-stream::-webkit-scrollbar-thumb:hover,
.deal-email-body::-webkit-scrollbar-thumb:hover {
    background: var(--deal-accent-color, #ef6f2a) padding-box;
}

.deal-detail-panel--center {
    align-content: start;
}

.deal-email-toolbar {
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 20%, var(--color-border));
    border-radius: 18px;
    background: linear-gradient(135deg, var(--deal-accent-surface-light, rgba(239, 111, 42, 0.1)), var(--color-bg-surface) 68%);
    padding: 16px;
}

.deal-email-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 18px;
}

.deal-email-filters label {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.deal-email-filters .app-form-control {
    min-width: 0;
    text-transform: none;
}

.deal-email-filter-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 12px;
    color: var(--deal-accent-color, #ef6f2a);
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 800;
}

.deal-email-filter-reset:hover {
    background: var(--deal-accent-surface-light, rgba(239, 111, 42, 0.1));
}

.deal-activity-stream {
    position: relative;
    min-height: 300px;
    max-height: min(72vh, 780px);
    overflow-x: clip;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 8px 2px 2px;
}

.deal-activity-items,
.deal-email-list {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.deal-email-card {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 14%, var(--color-border));
    border-radius: 20px;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 4%, var(--color-bg-surface)), var(--color-bg-surface) 46%);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 7%, transparent);
    padding: 18px;
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.deal-email-card::before {
    position: absolute;
    inset: 18px auto 18px 0;
    width: 3px;
    border-radius: 0 999px 999px 0;
    background: var(--deal-accent-color, #ef6f2a);
    content: "";
    opacity: 0.7;
}

.deal-email-card:hover {
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 38%, var(--color-border));
    box-shadow: 0 18px 42px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 12%, transparent);
    transform: translateY(-1px);
}

.deal-email-card__head {
    align-items: center;
}

.deal-email-identity {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.deal-email-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid color-mix(in srgb, var(--identity-color) 36%, transparent);
    border-radius: 14px;
    background: color-mix(in srgb, var(--identity-color) 14%, var(--color-bg-surface));
    color: var(--identity-color);
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.deal-email-card__subject {
    font-size: 1rem;
    font-weight: 800;
}

.deal-email-direction {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 6px;
    align-items: center;
    border: 1px solid color-mix(in srgb, #10b981 32%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, #10b981 10%, var(--color-bg-surface));
    color: #059669;
    padding: 6px 10px;
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.deal-email-participants {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.deal-email-recipient-list {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.deal-email-participant-arrow {
    flex: 0 0 auto;
    color: var(--color-text-tertiary);
    font-weight: 900;
}

.deal-participant-chip {
    display: grid;
    min-width: 0;
    max-width: 100%;
    border: 1px solid color-mix(in srgb, var(--identity-color) 28%, var(--color-border));
    border-radius: 13px;
    background: color-mix(in srgb, var(--identity-color) 8%, var(--color-bg-surface));
    color: var(--identity-color);
    padding: 8px 11px;
}

.deal-participant-chip.is-neutral {
    --identity-color: var(--color-text-secondary);
}

.deal-participant-chip__role {
    font-size: 0.6rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    opacity: 0.72;
    text-transform: uppercase;
}

.deal-participant-chip strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-participant-chip small {
    overflow: hidden;
    color: var(--color-text-tertiary);
    font-size: 0.68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.identity-color-0 { --identity-color: #2563eb; }
.identity-color-1 { --identity-color: #7c3aed; }
.identity-color-2 { --identity-color: #db2777; }
.identity-color-3 { --identity-color: #ea580c; }
.identity-color-4 { --identity-color: #0891b2; }
.identity-color-5 { --identity-color: #059669; }
.identity-color-6 { --identity-color: #ca8a04; }
.identity-color-7 { --identity-color: #4f46e5; }

.deal-email-reading-pane {
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--color-bg-subtle) 68%, var(--color-bg-surface));
}

.deal-email-preview {
    margin: 0;
    padding: 15px 16px;
    color: var(--color-text-secondary);
    font-size: 0.84rem;
    line-height: 1.7;
    white-space: pre-line;
}

.deal-email-details {
    border-top: 1px solid var(--color-border);
    padding: 0;
}

.deal-email-details summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    color: var(--deal-accent-color, #ef6f2a);
    list-style: none;
}

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

.deal-email-details__chevron {
    transition: transform 180ms ease;
}

.deal-email-details[open] .deal-email-details__chevron {
    transform: rotate(180deg);
}

.deal-email-body {
    max-height: 460px;
    margin: 0;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-surface);
    padding: 18px;
    white-space: normal;
}

.deal-email-body a {
    color: var(--deal-accent-color, #ef6f2a);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.deal-email-card__footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.deal-email-card__footer-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.deal-email-match {
    color: var(--color-text-tertiary);
    font-size: 0.7rem;
    font-weight: 700;
}

.deal-email-outlook-link {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--deal-accent-color, #ef6f2a);
    font-size: 0.74rem;
    font-weight: 850;
}

.deal-email-reply-action,
.deal-email-reply-cancel {
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 28%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 8%, var(--color-bg-surface));
    color: var(--deal-accent-color, #ef6f2a);
    padding: 6px 11px;
    font-size: 0.72rem;
    font-weight: 850;
}

.deal-email-reply-action:hover,
.deal-email-reply-cancel:hover {
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 14%, var(--color-bg-surface));
}

.deal-email-inline-reply {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    min-width: 0;
    border-top: 1px solid var(--color-border);
    padding-top: 14px;
}

.deal-email-inline-reply[hidden] {
    display: none;
}

.deal-email-inline-reply > label {
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    font-weight: 800;
}

.deal-email-inline-reply > div {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.deal-email-inline-reply textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    resize: vertical;
}

.deal-activity-loader {
    display: flex;
    gap: 9px;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    color: var(--color-text-tertiary);
    font-size: 0.74rem;
    font-weight: 750;
}

.deal-activity-loader[hidden] {
    display: none;
}

.deal-activity-loader__spinner {
    width: 17px;
    height: 17px;
    border: 2px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 24%, transparent);
    border-top-color: var(--deal-accent-color, #ef6f2a);
    border-radius: 50%;
    animation: deal-activity-spin 800ms linear infinite;
}

.deal-activity-loader:not(.is-loading) .deal-activity-loader__spinner {
    opacity: 0.35;
    animation-play-state: paused;
}

.deal-activity-loader.has-error {
    color: #e11d48;
}

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

html[data-theme="dark"] .deal-email-toolbar {
    background: linear-gradient(135deg, var(--deal-accent-surface-dark, rgba(239, 111, 42, 0.14)), var(--color-bg-surface) 68%);
}

html[data-theme="dark"] .deal-email-filter-reset:hover {
    background: var(--deal-accent-surface-dark, rgba(239, 111, 42, 0.14));
}

@media (max-width: 767px) {
    .deal-email-filters {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-activity-stream {
        max-height: 72vh;
        padding-right: 3px;
    }

    .deal-email-card__head,
    .deal-email-participants {
        align-items: flex-start;
    }

    .deal-email-participants {
        flex-direction: column;
    }

    .deal-email-participant-arrow {
        margin-left: 18px;
        transform: rotate(90deg);
    }

    .deal-email-recipient-list,
    .deal-participant-chip {
        width: 100%;
    }
}

/* Preloaded deal activity panels and modern email controls */
.deal-activity-panels,
.deal-activity-panel {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.deal-activity-panel[hidden] {
    display: none;
}

.deal-email-sync-state {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 7px;
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 24%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 7%, var(--color-bg-surface));
    color: var(--color-text-secondary);
    padding: 7px 10px;
    font-size: 0.68rem;
    font-weight: 800;
}

.deal-email-sync-state > span:first-child {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--deal-accent-color, #ef6f2a);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 15%, transparent);
    animation: deal-sync-pulse 1.1s ease-in-out infinite;
}

.deal-email-sync-state.is-complete {
    border-color: color-mix(in srgb, #10b981 28%, var(--color-border));
    color: #059669;
}

.deal-email-sync-state.is-complete > span:first-child {
    background: #10b981;
    box-shadow: none;
    animation: none;
}

.deal-email-sync-state.has-error {
    border-color: color-mix(in srgb, #e11d48 28%, var(--color-border));
    color: #e11d48;
}

.deal-email-sync-state.has-error > span:first-child {
    background: #e11d48;
    box-shadow: none;
    animation: none;
}

@keyframes deal-sync-pulse {
    50% { opacity: 0.42; transform: scale(0.82); }
}

.deal-email-filters {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    overflow: visible;
}

.deal-filter-field {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.deal-filter-field__label {
    color: var(--color-text-secondary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.deal-filter-menu {
    position: relative;
    min-width: 0;
}

.deal-filter-menu > summary {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-bg-surface);
    color: var(--color-text-primary);
    cursor: pointer;
    list-style: none;
    padding: 8px 12px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.deal-filter-menu > summary::-webkit-details-marker {
    display: none;
}

.deal-filter-menu[open] > summary,
.deal-filter-menu > summary:hover {
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 50%, var(--color-border));
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 5%, var(--color-bg-surface));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 10%, transparent);
}

.deal-filter-summary-copy,
.deal-filter-options button > span {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    min-width: 0;
}

.deal-filter-summary-copy strong,
.deal-filter-options strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-filter-summary-copy small,
.deal-filter-options small {
    grid-column: 2;
    overflow: hidden;
    color: var(--color-text-tertiary);
    font-size: 0.65rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-filter-dot {
    grid-row: 1 / span 2;
    width: 10px;
    height: 10px;
    border-radius: 4px;
    background: var(--identity-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--identity-color) 12%, transparent);
}

.deal-filter-dot.is-neutral {
    --identity-color: var(--color-text-tertiary);
}

.deal-filter-chevron {
    color: var(--color-text-tertiary);
    font-size: 0.9rem;
    transition: transform 160ms ease;
}

.deal-filter-menu[open] .deal-filter-chevron {
    transform: rotate(180deg);
}

.deal-filter-options {
    position: absolute;
    z-index: 40;
    top: calc(100% + 8px);
    left: 0;
    display: grid;
    width: max(100%, 260px);
    max-height: 280px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 18%, var(--color-border));
    border-radius: 16px;
    background: var(--color-bg-surface);
    box-shadow: 0 22px 55px rgba(15, 23, 42, 0.18);
    padding: 7px;
    scrollbar-gutter: stable;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

.deal-filter-options button {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-radius: 11px;
    color: var(--color-text-primary);
    padding: 9px 10px;
    text-align: left;
}

.deal-filter-options button:hover,
.deal-filter-options button.is-selected {
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 9%, var(--color-bg-surface));
}

.deal-filter-check {
    color: var(--deal-accent-color, #ef6f2a);
    font-size: 0.75rem;
    font-style: normal;
    font-weight: 900;
    opacity: 0;
}

.deal-filter-options button.is-selected .deal-filter-check {
    opacity: 1;
}

.deal-email-filter-reset[hidden] {
    display: none;
}

.deal-email-card.is-incoming::before {
    background: #0891b2;
}

.deal-email-card.is-incoming {
    border-color: color-mix(in srgb, #0891b2 20%, var(--color-border));
    background: linear-gradient(145deg, color-mix(in srgb, #0891b2 5%, var(--color-bg-surface)), var(--color-bg-surface) 48%);
}

.deal-email-direction.is-incoming {
    border-color: color-mix(in srgb, #0891b2 30%, transparent);
    background: color-mix(in srgb, #0891b2 10%, var(--color-bg-surface));
    color: #0891b2;
}

.deal-email-card.is-collapsible {
    cursor: pointer;
}

.deal-email-card.is-collapsible:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 30%, transparent);
    outline-offset: 2px;
}

.deal-email-reading-pane {
    position: relative;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 22%, var(--color-border));
    border-left: 4px solid var(--deal-accent-color, #ef6f2a);
    border-radius: 12px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 4%, var(--color-bg-surface));
    box-shadow: 0 8px 24px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 7%, transparent);
}

.deal-email-reading-pane__label {
    display: flex;
    gap: 7px;
    align-items: center;
    border-bottom: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 16%, var(--color-border));
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 8%, var(--color-bg-surface));
    color: var(--deal-accent-color, #ef6f2a);
    padding: 9px 18px;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.deal-email-body {
    max-height: none;
    overflow: visible;
    border-top: 0;
    background: transparent;
    color: var(--color-text-primary);
    padding: 20px;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.78;
}

.deal-email-card.is-collapsible:not(.is-expanded) .deal-email-body {
    max-height: calc(10 * 1.78em + 40px);
    overflow: hidden;
}

.deal-email-card.is-collapsible:not(.is-expanded) .deal-email-reading-pane::after {
    position: absolute;
    right: 0;
    bottom: 34px;
    left: 0;
    height: 56px;
    background: linear-gradient(
        transparent,
        color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 4%, var(--color-bg-surface))
    );
    content: "";
    pointer-events: none;
}

.deal-email-expand-hint {
    position: relative;
    z-index: 1;
    display: block;
    border-top: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 7%, var(--color-bg-surface));
    color: var(--deal-accent-color, #ef6f2a);
    padding: 10px 16px;
    font-size: 0.68rem;
    font-weight: 850;
    text-align: center;
}

@media (max-width: 767px) {
    .deal-email-filters {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-filter-options {
        width: 100%;
    }

    .deal-email-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Deal document workspace */
.deal-documents {
    display: grid;
    gap: 14px;
}

.deal-documents__header {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    padding: 2px 2px 14px;
}

.deal-documents__total {
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg-subtle);
    color: var(--color-text-secondary);
    padding: 6px 10px;
    font-size: 0.68rem;
    font-weight: 800;
}

.deal-document-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: thin;
}

.deal-document-selection-bar {
    position: sticky;
    top: 8px;
    z-index: 8;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 38%, var(--color-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 9%, var(--color-bg-surface));
    padding: 9px 10px 9px 13px;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.16);
    color: var(--color-text-secondary);
    font-size: 0.68rem;
}

.deal-document-selection-bar[hidden] {
    display: none;
}

.deal-document-selection-bar > span {
    white-space: nowrap;
}

.deal-document-selection-bar > span strong {
    color: var(--color-text-primary);
    font-size: 0.78rem;
}

.deal-document-selection-bar > div {
    display: flex;
    gap: 6px;
}

.deal-document-selection-action {
    min-height: 32px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
    padding: 6px 10px;
    font-size: 0.63rem;
    font-weight: 850;
    cursor: pointer;
}

.deal-document-selection-action.is-primary {
    border-color: transparent;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
}

.deal-document-selection-action.is-danger {
    border-color: color-mix(in srgb, #dc2626 30%, var(--color-border));
    color: #dc2626;
}

.deal-document-selection-action:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.deal-document-tab {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 8px;
    align-items: center;
    min-height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 13px;
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
    padding: 8px 11px;
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.deal-document-panels,
.deal-document-panel {
    display: grid;
    gap: 14px;
}

.deal-document-tab small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    min-height: 22px;
    border-radius: 999px;
    background: var(--color-bg-subtle);
    color: var(--color-text-tertiary);
    padding: 2px 6px;
    font-size: 0.62rem;
}

.deal-document-tab:hover,
.deal-document-tab.is-active {
    border-color: color-mix(in srgb, var(--document-tab-color, var(--deal-accent-color, #ef6f2a)) 45%, var(--color-border));
    background: color-mix(in srgb, var(--document-tab-color, var(--deal-accent-color, #ef6f2a)) 10%, var(--color-bg-surface));
    color: var(--color-text-primary);
}

.deal-document-upload {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.34fr);
    gap: 10px;
    border: 1px dashed color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 44%, var(--color-border));
    border-radius: 16px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 5%, var(--color-bg-surface));
    padding: 12px;
}

.deal-document-upload__picker {
    position: relative;
    display: flex;
    gap: 11px;
    align-items: center;
    min-width: 0;
    cursor: pointer;
}

.deal-document-upload__picker input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.deal-document-upload__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
    font-size: 1.2rem;
    font-weight: 900;
}

.deal-document-upload__picker > span:not(.deal-document-upload__icon) {
    display: grid;
    min-width: 0;
}

.deal-document-upload__picker strong {
    color: var(--color-text-primary);
    font-size: 0.74rem;
}

.deal-document-upload__picker small {
    margin-top: 3px;
    color: var(--color-text-tertiary);
    font-size: 0.63rem;
}

.deal-document-recent-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 1px solid color-mix(in srgb, #3b82f6 24%, var(--color-border));
    border-radius: 15px;
    background: color-mix(in srgb, #3b82f6 7%, var(--color-bg-surface));
    padding: 11px 13px;
    color: #2563eb;
}

.deal-document-recent-note p {
    display: grid;
    color: var(--color-text-primary);
    font-size: 0.72rem;
}

.deal-document-recent-note small {
    margin-top: 3px;
    color: var(--color-text-tertiary);
    font-size: 0.64rem;
    line-height: 1.45;
}

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

.deal-document-card {
    position: relative;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-bg-surface);
    padding: 13px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.deal-document-card.is-selected {
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 58%, var(--color-border));
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 6%, var(--color-bg-surface));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 11%, transparent);
}

.deal-document-select {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: inline-flex;
    width: 22px;
    height: 22px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-3px);
    transition: opacity 0.15s, transform 0.15s;
    cursor: pointer;
}

.deal-document-card:hover .deal-document-select,
.deal-document-select:focus-within,
.deal-document-card.is-selected .deal-document-select {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.deal-document-select input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.deal-document-select span {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border-strong);
    border-radius: 7px;
    background: var(--color-bg-surface);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

.deal-document-select input:focus-visible + span {
    outline: 3px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 28%, transparent);
    outline-offset: 2px;
}

.deal-document-select input:checked + span {
    border-color: var(--deal-accent-color, #ef6f2a);
    background: var(--deal-accent-color, #ef6f2a);
}

.deal-document-select input:checked + span::after {
    content: "";
    width: 8px;
    height: 4px;
    border-bottom: 2px solid white;
    border-left: 2px solid white;
    transform: translateY(-1px) rotate(-45deg);
}

.deal-document-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 12%, var(--color-bg-subtle));
    color: var(--deal-accent-color, #ef6f2a);
}

.deal-document-card__icon svg {
    width: 20px;
    height: 20px;
}

.deal-document-card__main {
    min-width: 0;
}

.deal-document-card__title-row {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.deal-document-card__title-row > strong {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-document-card__main > p {
    margin-top: 3px;
    color: var(--color-text-tertiary);
    font-size: 0.64rem;
}

.deal-document-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 11px;
    margin-top: 7px;
    color: var(--color-text-secondary);
    font-size: 0.63rem;
}

.deal-document-email-tag {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 5px;
    align-items: center;
    border-radius: 999px;
    background: color-mix(in srgb, #3b82f6 11%, var(--color-bg-subtle));
    color: #2563eb;
    padding: 4px 7px;
    font-size: 0.6rem;
    font-weight: 850;
}

.deal-document-card__actions,
.deal-document-categorize {
    display: flex;
    gap: 7px;
    align-items: center;
}

.deal-document-card__actions {
    grid-column: 2;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.deal-document-categorize .app-form-control {
    min-width: 132px;
    min-height: 36px;
    padding: 7px 28px 7px 9px;
    font-size: 0.66rem;
}

.deal-document-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--color-border);
    border-radius: 11px;
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
    padding: 7px 10px;
    font-size: 0.64rem;
    font-weight: 800;
}

.deal-document-action.is-primary {
    border-color: transparent;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
}

.deal-document-action.is-danger {
    border-color: color-mix(in srgb, #dc2626 28%, var(--color-border));
    background: color-mix(in srgb, #dc2626 6%, var(--color-bg-surface));
    color: #dc2626;
}

.deal-document-action.is-danger:hover,
.deal-document-action.is-danger:focus-visible {
    border-color: #dc2626;
    background: color-mix(in srgb, #dc2626 11%, var(--color-bg-surface));
    outline: none;
}

.deal-document-action:disabled {
    cursor: wait;
    opacity: 0.62;
}

.deal-document-move-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.deal-document-move-modal[hidden] {
    display: none;
}

.deal-document-move-modal__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(4px);
}

.deal-document-move-dialog {
    position: relative;
    z-index: 1;
    width: min(390px, 100%);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.3);
}

.deal-document-move-dialog > header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    justify-content: space-between;
}

.deal-document-move-dialog h3 {
    margin-top: 4px;
    color: var(--color-text-primary);
    font-size: 1rem;
    font-weight: 850;
}

.deal-document-move-close {
    display: inline-flex;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.deal-document-move-dialog form,
.deal-document-move-dialog label {
    display: grid;
    gap: 7px;
}

.deal-document-move-dialog form {
    margin-top: 16px;
}

.deal-document-move-dialog label > span {
    color: var(--color-text-secondary);
    font-size: 0.68rem;
    font-weight: 800;
}

.deal-document-move-dialog footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.deal-document-action-error {
    border-radius: 10px;
    background: color-mix(in srgb, #dc2626 9%, var(--color-bg-surface));
    color: #dc2626;
    padding: 8px 10px;
    font-size: 0.66rem;
}

.deal-document-empty {
    display: grid;
    justify-items: center;
    border: 1px dashed var(--color-border-strong);
    border-radius: 18px;
    padding: 30px 18px;
    text-align: center;
}

.deal-document-empty > span {
    color: var(--deal-accent-color, #ef6f2a);
    font-size: 2rem;
}

.deal-document-empty h3 {
    margin-top: 7px;
    color: var(--color-text-primary);
    font-size: 0.86rem;
    font-weight: 850;
}

.deal-document-empty p,
.deal-document-empty a {
    margin-top: 5px;
    color: var(--color-text-tertiary);
    font-size: 0.68rem;
}

.deal-document-empty a {
    color: var(--deal-accent-color, #ef6f2a);
    font-weight: 800;
}

.deal-email-card.is-linked-source,
.deal-email-card:target {
    border-color: color-mix(in srgb, #3b82f6 52%, var(--color-border));
    box-shadow: 0 0 0 3px color-mix(in srgb, #3b82f6 12%, transparent);
}

html[data-theme="dark"] .deal-document-email-tag,
html.dark .deal-document-email-tag,
html[data-theme="dark"] .deal-document-recent-note,
html.dark .deal-document-recent-note {
    color: #93c5fd;
}

@media (max-width: 980px) {
    .deal-document-card__actions {
        grid-column: 2;
    }
}

@media (max-width: 640px) {
    .deal-documents__header,
    .deal-document-card__title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .deal-document-upload {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-document-selection-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .deal-document-selection-bar > div,
    .deal-document-selection-action {
        flex: 1;
    }

    .deal-document-card {
        grid-template-columns: 36px minmax(0, 1fr);
        padding: 11px;
    }

    .deal-document-card__icon {
        width: 36px;
        height: 36px;
    }

    .deal-document-card__actions,
    .deal-document-categorize {
        align-items: stretch;
        flex-direction: column;
    }

    .deal-document-card__actions {
        grid-column: 1 / -1;
    }

    .deal-document-card__actions > *,
    .deal-document-action,
    .deal-document-categorize .app-form-control {
        width: 100%;
    }
}

/* Modular deal email discovery controls */
.deal-email-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
    overflow: visible;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 18%, var(--color-border));
    border-radius: 18px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 3%, var(--color-bg-surface));
    padding: 16px;
}

.deal-email-filters[aria-busy="true"] .deal-email-filter-status {
    color: var(--deal-accent-color, #ef6f2a);
}

.deal-email-filter-head,
.deal-email-search-row,
.deal-email-quick-filters,
.deal-email-more-filters > summary,
.deal-email-advanced-grid,
.deal-email-custom-dates {
    min-width: 0;
}

.deal-email-filter-head {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
}

.deal-email-filter-title {
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 850;
}

.deal-email-filter-status {
    margin-top: 2px;
    color: var(--color-text-tertiary);
    font-size: 0.7rem;
    font-weight: 700;
    transition: color 160ms ease;
}

.deal-email-filter-reset {
    gap: 7px;
    min-height: 36px;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 25%, var(--color-border));
    background: var(--color-bg-surface);
    padding-inline: 11px;
}

.deal-email-filter-reset [data-filter-count],
.deal-email-more-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
    padding-inline: 5px;
    font-size: 0.64rem;
    font-weight: 900;
}

.deal-email-search-row {
    display: grid;
    grid-template-columns: minmax(128px, 0.32fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.deal-email-filters label,
.deal-email-direction-filter {
    min-width: 0;
    text-transform: none;
}

.deal-email-search-scope,
.deal-email-search-box,
.deal-email-direction-filter {
    display: grid;
    gap: 7px;
}

.deal-email-search-input-wrap {
    min-width: 0;
}

.deal-email-more-count[hidden] {
    display: none;
}

.deal-email-search-submit {
    min-height: 46px;
    border-radius: 13px;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
    padding: 0 14px;
    font-size: 0.76rem;
    font-weight: 850;
    box-shadow: 0 10px 22px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 18%, transparent);
}

.deal-email-search-submit:hover {
    filter: brightness(0.96);
    transform: translateY(-1px);
}

.deal-email-quick-filters {
    display: grid;
    grid-template-columns: minmax(260px, 1.35fr) minmax(140px, 0.82fr);
    gap: 10px;
    align-items: end;
}

.deal-detail-panel--center {
    container-type: inline-size;
}

.deal-email-direction-filter {
    margin: 0;
    border: 0;
    padding: 0;
}

.deal-email-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    min-height: 46px;
    border: 1px solid var(--color-border);
    border-radius: 13px;
    background: var(--color-bg-subtle);
    padding: 4px;
}

.deal-email-segmented button {
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    font-weight: 800;
}

.deal-email-segmented button:hover {
    color: var(--color-text-primary);
}

.deal-email-segmented button.is-selected {
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 24%, var(--color-border));
    background: var(--color-bg-surface);
    color: var(--deal-accent-color, #ef6f2a);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.deal-email-quick-filters .app-form-control,
.deal-email-search-scope .app-form-control,
.deal-email-custom-dates .app-form-control {
    min-height: 46px;
}

.deal-email-more-filters {
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

.deal-email-more-filters > summary {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--color-text-primary);
    cursor: pointer;
    list-style: none;
}

.deal-email-more-filters > summary::-webkit-details-marker {
    display: none;
}

.deal-email-more-filters > summary > span:first-child {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
}

.deal-email-more-filters > summary strong {
    font-size: 0.76rem;
    font-weight: 850;
}

.deal-email-more-filters > summary small {
    margin-top: 2px;
    color: var(--color-text-tertiary);
    font-size: 0.66rem;
}

.deal-email-more-filters[open] > summary .deal-filter-chevron {
    transform: rotate(180deg);
}

.deal-email-advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-top: 14px;
}

.deal-email-custom-dates {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    border: 1px dashed color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 28%, var(--color-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 4%, var(--color-bg-subtle));
    padding: 12px;
}

.deal-email-custom-dates[hidden] {
    display: none;
}

html[data-theme="dark"] .deal-email-filters {
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 5%, var(--color-bg-surface));
}

@media (max-width: 1100px) {
    .deal-email-search-row {
        grid-template-columns: minmax(140px, 0.4fr) minmax(180px, 1fr);
    }

    .deal-email-search-submit {
        grid-column: 1 / -1;
    }

    .deal-email-quick-filters {
        grid-template-columns: minmax(0, 1fr) minmax(130px, 0.7fr);
    }

}

@container (max-width: 650px) {
    .deal-email-search-row {
        grid-template-columns: minmax(118px, 0.42fr) minmax(0, 1fr) auto;
    }

    .deal-email-quick-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .deal-email-direction-filter {
        grid-column: 1 / -1;
    }
}

@container (max-width: 430px) {
    .deal-email-search-row,
    .deal-email-quick-filters,
    .deal-email-advanced-grid,
    .deal-email-custom-dates {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-email-search-submit,
    .deal-email-quick-filters > :last-child,
    .deal-email-direction-filter,
    .deal-email-custom-dates {
        grid-column: auto;
    }
}

.deal-email-summary-row {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    border-bottom: 1px solid var(--color-border);
    padding: 2px 2px 14px;
}

.deal-email-summary-row__eyebrow {
    color: var(--color-text-primary);
    font-size: 0.76rem;
    font-weight: 850;
}

.deal-email-summary-row__copy {
    margin-top: 2px;
    color: var(--color-text-tertiary);
    font-size: 0.68rem;
}

.deal-email-summary-stats {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

.deal-email-summary-stat {
    display: grid;
    grid-template-columns: auto auto;
    gap: 6px;
    align-items: baseline;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 22%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 6%, var(--color-bg-surface));
    padding: 7px 10px;
}

.deal-email-summary-stat strong {
    color: var(--deal-accent-color, #ef6f2a);
    font-size: 0.84rem;
    font-weight: 900;
}

.deal-email-summary-stat small {
    color: var(--color-text-secondary);
    font-size: 0.65rem;
    font-weight: 750;
}

.deal-email-filter-disclosure {
    position: relative;
    overflow: visible;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 18%, var(--color-border));
    border-radius: 16px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 3%, var(--color-bg-surface));
}

.deal-email-filter-disclosure > summary {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 54px;
    color: var(--color-text-primary);
    cursor: pointer;
    list-style: none;
    padding: 10px 13px;
}

.deal-email-filter-disclosure > summary::-webkit-details-marker {
    display: none;
}

.deal-email-filter-disclosure__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 10%, var(--color-bg-surface));
    color: var(--deal-accent-color, #ef6f2a);
    font-size: 1rem;
    font-weight: 900;
}

.deal-email-filter-disclosure__copy {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
}

.deal-email-filter-disclosure__copy strong {
    font-size: 0.78rem;
    font-weight: 850;
}

.deal-email-filter-disclosure__copy small {
    margin-top: 1px;
    color: var(--color-text-tertiary);
    font-size: 0.65rem;
}

.deal-email-filter-disclosure[open] > summary {
    border-bottom: 1px solid var(--color-border);
}

.deal-email-filter-disclosure[open] > summary .deal-filter-chevron {
    transform: rotate(180deg);
}

.deal-email-filter-disclosure > .deal-email-filters {
    gap: 12px;
    border: 0;
    border-radius: 0 0 15px 15px;
    background: transparent;
    padding: 14px;
}

.deal-email-filter-disclosure .deal-email-filter-title {
    font-size: 0.82rem;
}

.deal-email-filter-disclosure .deal-email-search-input-wrap,
.deal-email-filter-disclosure .deal-email-quick-filters .app-form-control,
.deal-email-filter-disclosure .deal-email-search-scope .app-form-control,
.deal-email-filter-disclosure .deal-email-custom-dates .app-form-control,
.deal-email-filter-disclosure .deal-email-segmented {
    min-height: 42px;
}

.deal-email-filter-apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
    font-size: 0.76rem;
    font-weight: 850;
    box-shadow: 0 10px 22px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 18%, transparent);
}

.deal-email-filter-apply:hover {
    filter: brightness(0.96);
    transform: translateY(-1px);
}

.deal-email-card__actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    justify-content: flex-end;
}

.deal-email-reply-badge {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    min-height: 28px;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 26%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 8%, var(--color-bg-surface));
    color: var(--deal-accent-color, #ef6f2a);
    padding: 5px 9px;
    font-size: 0.65rem;
    font-weight: 850;
}

button.deal-email-reply-badge:hover,
button.deal-email-reply-badge[aria-expanded="true"] {
    border-color: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 48%, var(--color-border));
    background: color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 14%, var(--color-bg-surface));
}

.deal-email-reply-badge.is-static {
    color: var(--color-text-secondary);
}

.deal-email-reply-history {
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 20%, var(--color-border));
    border-radius: 15px;
    background: color-mix(in srgb, var(--color-bg-subtle) 82%, var(--color-bg-surface));
}

.deal-email-reply-history[hidden] {
    display: none;
}

.deal-email-reply-history > header {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    padding: 10px 13px;
}

.deal-email-reply-history > header strong {
    color: var(--color-text-primary);
    font-size: 0.72rem;
    font-weight: 850;
}

.deal-email-reply-history > header span {
    color: var(--color-text-tertiary);
    font-size: 0.62rem;
    font-weight: 700;
}

.deal-email-reply-history__body {
    max-height: 340px;
    overflow: auto;
    padding: 13px;
    color: var(--color-text-secondary);
    font-size: 0.76rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.deal-email-reply-history__body a {
    color: var(--deal-accent-color, #ef6f2a);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.deal-participant-chip__role.is-cc {
    justify-self: start;
    border-radius: 999px;
    background: color-mix(in srgb, #8b5cf6 13%, transparent);
    color: #7c3aed;
    padding: 2px 6px;
    opacity: 1;
}

html.dark .deal-card:hover,
html[data-theme="dark"] .deal-card:hover {
    border-color: var(--deal-accent-border-dark) !important;
    background: color-mix(in srgb, var(--color-bg-surface) 92%, var(--deal-accent-color, #ef6f2a)) !important;
    color: var(--color-text-primary) !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.34);
}

html.dark .deal-card:hover .deal-card-title,
html.dark .deal-card:hover .deal-card__meta-label,
html[data-theme="dark"] .deal-card:hover .deal-card-title,
html[data-theme="dark"] .deal-card:hover .deal-card__meta-label {
    color: var(--color-text-primary);
}

html.dark .deal-card:hover .deal-card-meta,
html[data-theme="dark"] .deal-card:hover .deal-card-meta {
    color: var(--color-text-secondary);
}

@media (max-width: 767px) {
    .deal-email-filter-head {
        align-items: flex-start;
    }

    .deal-email-search-row,
    .deal-email-quick-filters,
    .deal-email-advanced-grid,
    .deal-email-custom-dates {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-email-search-submit,
    .deal-email-quick-filters > :last-child,
    .deal-email-custom-dates {
        grid-column: auto;
    }

    .deal-email-more-filters > summary small {
        display: none;
    }

    .deal-email-summary-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .deal-email-summary-stats {
        width: 100%;
    }

    .deal-email-summary-stat {
        flex: 1 1 0;
        justify-content: center;
    }

    .deal-email-card__actions {
        justify-content: flex-start;
    }
}

.deal-activity-composer {
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 22%, var(--color-border));
    border-radius: 18px;
    background: linear-gradient(135deg, var(--deal-accent-surface-light, rgba(239, 111, 42, 0.1)), var(--color-bg-surface) 74%);
}

.deal-activity-composer > summary {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    cursor: pointer;
    list-style: none;
}

.deal-activity-composer > summary::-webkit-details-marker {
    display: none;
}

.deal-activity-composer > summary > span:first-child {
    display: grid;
    gap: 3px;
}

.deal-activity-composer > summary strong {
    color: var(--color-text-primary);
    font-size: 0.9rem;
}

.deal-activity-composer > summary small {
    color: var(--color-text-tertiary);
    font-size: 0.72rem;
}

.deal-activity-composer__action {
    border-radius: 999px;
    background: var(--deal-accent-color, #ef6f2a);
    color: white;
    padding: 7px 11px;
    font-size: 0.7rem;
    font-weight: 850;
}

.deal-activity-composer__form {
    display: grid;
    gap: 13px;
    border-top: 1px solid var(--color-border);
    padding: 16px;
}

.deal-activity-composer__form label {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.deal-activity-composer__form label > span {
    color: var(--color-text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.deal-email-composer__from {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 10px;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-subtle);
    padding: 11px 12px;
}

.deal-email-composer__from > span {
    grid-row: 1 / 3;
    color: var(--color-text-tertiary);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.deal-email-composer__from > strong {
    color: var(--color-text-primary);
    font-size: 0.78rem;
}

.deal-email-composer__from > small,
.deal-email-composer__form label > small {
    color: var(--color-text-tertiary);
    font-size: 0.68rem;
}

.deal-email-composer__connect {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--color-border);
    padding: 16px;
}

.deal-email-composer__connect p,
.deal-email-composer__notice {
    color: var(--color-text-secondary);
    font-size: 0.76rem;
    line-height: 1.55;
}

.deal-email-composer__notice {
    border-radius: 12px;
    background: var(--color-bg-subtle);
    padding: 12px;
}

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

.deal-call-composer-grid__wide {
    grid-column: 1 / -1;
}

.deal-timeline-card {
    display: grid;
    gap: 14px;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 18px;
    background: var(--color-bg-surface);
    box-shadow: 0 10px 26px color-mix(in srgb, var(--deal-accent-color, #ef6f2a) 6%, transparent);
    padding: 17px;
}

.deal-note-card {
    border-left: 3px solid #eab308;
    background: linear-gradient(145deg, color-mix(in srgb, #eab308 5%, var(--color-bg-surface)), var(--color-bg-surface));
}

.deal-call-card {
    border-left: 3px solid #06b6d4;
    background: linear-gradient(145deg, color-mix(in srgb, #06b6d4 5%, var(--color-bg-surface)), var(--color-bg-surface));
}

.deal-timeline-card__head {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.deal-timeline-card__head > div {
    flex: 1 1 auto;
}

.deal-timeline-contact,
.deal-call-outcome {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    border: 1px solid color-mix(in srgb, var(--identity-color, var(--color-text-secondary)) 28%, var(--color-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--identity-color, var(--color-text-secondary)) 8%, var(--color-bg-surface));
    color: var(--identity-color, var(--color-text-secondary));
    padding: 6px 9px;
    font-size: 0.68rem;
    font-weight: 800;
}

.deal-call-outcome--connected { --identity-color: #059669; }
.deal-call-outcome--left_voicemail { --identity-color: #7c3aed; }
.deal-call-outcome--no_answer,
.deal-call-outcome--busy { --identity-color: #dc2626; }
.deal-call-outcome--follow_up { --identity-color: #d97706; }

.deal-timeline-copy {
    border-radius: 14px;
    background: color-mix(in srgb, var(--color-bg-subtle) 72%, var(--color-bg-surface));
    color: var(--color-text-secondary);
    padding: 14px 15px;
    font-size: 0.84rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.deal-timeline-copy a {
    color: var(--deal-accent-color, #ef6f2a);
    font-weight: 700;
    text-decoration: underline;
}

.deal-call-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.deal-call-facts > span:not(.deal-timeline-contact) {
    border-radius: 999px;
    background: var(--color-bg-subtle);
    color: var(--color-text-tertiary);
    padding: 6px 9px;
    font-size: 0.68rem;
    font-weight: 750;
}

html[data-theme="dark"] .deal-activity-composer {
    background: linear-gradient(135deg, var(--deal-accent-surface-dark, rgba(239, 111, 42, 0.14)), var(--color-bg-surface) 74%);
}

@media (max-width: 767px) {
    .deal-email-composer__connect {
        align-items: stretch;
        flex-direction: column;
    }

    .deal-call-composer-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .deal-call-composer-grid__wide {
        grid-column: auto;
    }

    .deal-timeline-card__head {
        align-items: flex-start;
        flex-wrap: wrap;
    }
}

/* Configurable contacts directory */
.crm-contact-directory-surface {
    gap: 0;
    padding: 0 !important;
}

.crm-contact-commandbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
}

.crm-contact-search {
    display: flex;
    min-width: 260px;
    flex: 1 1 580px;
    align-items: center;
    gap: 9px;
    max-width: 760px;
}

.crm-contact-search__submit {
    min-height: 42px;
    padding-inline: 16px;
}

.crm-contact-commandbar__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.crm-toolbar-button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    gap: 7px;
    padding-inline: 11px;
}

.crm-toolbar-button svg {
    width: 16px;
    height: 16px;
}

.crm-toolbar-button em {
    display: inline-flex;
    min-width: 19px;
    height: 19px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.6rem;
    font-style: normal;
    font-weight: 800;
}

.crm-contact-commandbar .crm-directory-count {
    margin-left: 4px;
    padding-left: 13px;
}

.crm-directory-panel {
    display: grid;
    gap: 16px;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-bg-subtle) 78%, var(--color-bg-surface));
    padding: 17px 18px;
    animation: crm-directory-panel-in 180ms ease-out;
}

.crm-directory-panel[hidden] {
    display: none !important;
}

@keyframes crm-directory-panel-in {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.crm-directory-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.crm-directory-panel__header > div {
    display: grid;
    gap: 3px;
}

.crm-directory-panel__header h2 {
    color: var(--color-text-primary);
    font-size: 0.94rem;
    font-weight: 760;
}

.crm-directory-panel__header > div > p:last-child:not(.bos-section-label) {
    color: var(--color-text-muted);
    font-size: 0.68rem;
}

.crm-filter-form {
    display: grid;
    align-items: end;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.crm-filter-field {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.crm-filter-field > span {
    color: var(--color-text-secondary);
    font-size: 0.66rem;
    font-weight: 720;
}

.crm-filter-field > .app-form-control,
.crm-filter-field > .bos-select,
.crm-filter-field .bos-select__trigger {
    width: 100%;
    min-height: 42px;
    border-radius: 11px !important;
}

.crm-filter-form__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    grid-column: span 1;
}

.crm-column-list {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 13px;
    background: var(--color-bg-surface);
}

.crm-column-option {
    display: grid;
    min-height: 54px;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border);
    padding: 8px 10px;
    grid-template-columns: 18px 20px minmax(0, 1fr) auto auto;
    cursor: grab;
    transition: background 140ms ease, opacity 140ms ease;
}

.crm-column-option:last-child {
    border-bottom: 0;
}

.crm-column-option:hover {
    background: var(--color-bg-subtle);
}

.crm-column-option.is-locked {
    cursor: default;
}

.crm-column-option.is-dragging {
    background: var(--color-accent-muted);
    opacity: 0.54;
}

.crm-column-option__handle {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    letter-spacing: -0.2em;
}

.crm-column-option input[type="checkbox"] {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    accent-color: var(--color-accent);
}

.crm-column-option > span:nth-of-type(2) {
    display: grid;
    gap: 2px;
}

.crm-column-option strong {
    color: var(--color-text-primary);
    font-size: 0.72rem;
}

.crm-column-option small {
    color: var(--color-text-muted);
    font-size: 0.63rem;
}

.crm-column-option > em {
    border-radius: 999px;
    background: var(--color-bg-subtle);
    padding: 4px 7px;
    color: var(--color-text-muted);
    font-size: 0.58rem;
    font-style: normal;
    font-weight: 750;
    text-transform: uppercase;
}

.crm-column-option__moves {
    display: inline-flex !important;
    grid-auto-flow: column;
    gap: 4px !important;
}

.crm-column-option__moves button {
    display: inline-flex;
    width: 29px;
    height: 29px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.crm-column-option__moves button:hover:not(:disabled) {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.crm-column-option__moves button:disabled {
    cursor: not-allowed;
    opacity: 0.34;
}

.crm-column-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.crm-record-table--configurable {
    border-top: 1px solid var(--color-border);
}

.crm-record-table__viewport {
    overflow-x: auto;
    scrollbar-width: thin;
}

.crm-record-table--configurable .crm-record-table__inner {
    min-width: var(--crm-contact-table-min-width);
}

.crm-record-table--configurable .crm-record-table__head,
.crm-record-table--configurable .crm-record-row {
    grid-template-columns: var(--crm-contact-grid-template);
    gap: 14px;
}

.crm-record-table--configurable .crm-record-table__head {
    min-height: 38px;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    padding: 7px 14px;
}

.crm-record-table--configurable .crm-record-list {
    gap: 0;
}

.crm-record-table--configurable .crm-record-row {
    min-height: 58px;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    padding: 8px 14px;
    box-shadow: none;
    transform: none;
}

.crm-record-table--configurable .crm-record-row:last-child {
    border-bottom: 0;
}

.crm-record-table--configurable .crm-record-row:hover {
    border-color: var(--color-border);
    background: var(--color-accent-muted);
    box-shadow: inset 3px 0 0 var(--color-accent);
    transform: none;
}

.crm-record-table--configurable .crm-record-identity {
    gap: 10px;
}

.crm-record-table--configurable .crm-record-identity > span:last-child,
.crm-record-table--configurable .crm-record-person {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.crm-record-table--configurable .crm-record-identity strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.78rem;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-record-table--configurable .crm-record-identity small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-record-table--configurable .crm-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.64rem;
}

.crm-record-table--configurable .crm-record-cell strong {
    font-size: 0.73rem;
}

.crm-record-table--configurable .crm-record-cell small {
    font-size: 0.64rem;
}

.crm-record-table--configurable .crm-record-arrow {
    width: 27px;
    height: 27px;
}

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

.crm-pagination p {
    color: var(--color-text-muted);
    font-size: 0.68rem;
}

.crm-pagination p strong {
    color: var(--color-text-secondary);
}

.crm-pagination__controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.crm-pagination__controls > a,
.crm-pagination__controls > span {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-secondary);
    font-size: 0.68rem;
    font-weight: 720;
}

.crm-pagination__controls > a:hover,
.crm-pagination__controls > .is-current {
    border-color: var(--color-accent);
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

.crm-pagination__controls > .is-disabled,
.crm-pagination__controls > .crm-pagination__ellipsis {
    border-color: transparent;
    opacity: 0.46;
}

@media (max-width: 1100px) {
    .crm-contact-commandbar {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-contact-search {
        max-width: none;
    }

    .crm-contact-commandbar__actions {
        flex-wrap: wrap;
    }

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

    .crm-filter-form__actions {
        grid-column: span 2;
    }
}

@media (max-width: 799px) {
    .crm-record-table--configurable .crm-record-table__head,
    .crm-record-table--configurable .crm-record-row {
        display: grid;
    }

    .crm-record-table--configurable .crm-record-cell {
        grid-column: auto;
        padding-left: 0;
    }

    .crm-record-table--configurable .crm-mobile-label {
        display: none;
    }

    .crm-record-table--configurable .crm-record-row > .crm-record-arrow {
        grid-column: auto;
        grid-row: auto;
    }
}

@media (max-width: 639px) {
    .crm-contact-search {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .crm-contact-commandbar__actions .crm-directory-count {
        width: 100%;
        border-top: 1px solid var(--color-border);
        border-left: 0;
        margin: 5px 0 0;
        padding: 10px 0 0;
    }

    .crm-filter-form {
        grid-template-columns: 1fr;
    }

    .crm-filter-form__actions {
        grid-column: auto;
    }

    .crm-pagination {
        align-items: flex-start;
        flex-direction: column;
    }

    .crm-column-option {
        grid-template-columns: 16px 20px minmax(0, 1fr) auto;
    }

    .crm-column-option > em {
        display: none;
    }
}

/* Contact data-quality center */
.crm-quality-alert {
    display: grid;
    align-items: center;
    gap: 13px;
    border: 1px solid color-mix(in srgb, var(--color-warning) 34%, var(--color-border));
    border-radius: 15px;
    background: linear-gradient(100deg, var(--color-warning-muted), var(--color-bg-surface) 68%);
    padding: 12px 14px;
    color: var(--color-text-primary);
    grid-template-columns: 42px minmax(0, 1fr) auto 30px;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.crm-quality-alert:hover {
    border-color: var(--color-warning);
    box-shadow: 0 12px 30px color-mix(in srgb, var(--color-warning) 12%, transparent);
    transform: translateY(-1px);
}

.crm-quality-alert.is-healthy {
    border-color: color-mix(in srgb, var(--color-success) 32%, var(--color-border));
    background: linear-gradient(100deg, var(--color-success-muted), var(--color-bg-surface) 68%);
}

.crm-quality-alert__icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: var(--color-bg-surface);
    box-shadow: inset 0 0 0 1px var(--color-border);
    color: var(--color-warning);
}

.crm-quality-alert.is-healthy .crm-quality-alert__icon {
    color: var(--color-success);
    font-weight: 800;
}

.crm-quality-alert__icon svg {
    width: 19px;
    height: 19px;
}

.crm-quality-alert__copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.crm-quality-alert__copy strong {
    color: var(--color-text-primary);
    font-size: 0.82rem;
}

.crm-quality-alert__copy small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 0.67rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-alert__score {
    display: grid;
    justify-items: end;
    gap: 1px;
}

.crm-quality-alert__score strong {
    color: var(--color-warning);
    font-size: 1rem;
    font-weight: 820;
}

.crm-quality-alert__score small {
    color: var(--color-text-muted);
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-quality-page {
    gap: 20px;
}

.crm-quality-overview {
    display: grid;
    align-items: center;
    gap: 24px;
    overflow: hidden;
    background:
        radial-gradient(circle at 8% 15%, var(--color-accent-muted), transparent 30%),
        var(--color-bg-surface) !important;
    grid-template-columns: auto minmax(0, 1fr) minmax(220px, 0.55fr);
}

.crm-quality-score {
    display: grid;
    width: 124px;
    height: 124px;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--color-accent) var(--crm-quality-score), var(--color-bg-subtle) 0);
    box-shadow: 0 16px 34px color-mix(in srgb, var(--color-accent) 14%, transparent);
}

.crm-quality-score::before {
    content: "";
    width: 98px;
    height: 98px;
    border-radius: inherit;
    background: var(--color-bg-surface);
    box-shadow: inset 0 0 0 1px var(--color-border);
    grid-area: 1 / 1;
}

.crm-quality-score > div {
    display: grid;
    z-index: 1;
    justify-items: center;
    gap: 1px;
    grid-area: 1 / 1;
}

.crm-quality-score strong {
    color: var(--color-accent);
    font-size: 1.45rem;
    font-weight: 850;
    letter-spacing: -0.04em;
}

.crm-quality-score span {
    color: var(--color-text-muted);
    font-size: 0.58rem;
    font-weight: 760;
    text-transform: uppercase;
}

.crm-quality-overview__copy {
    display: grid;
    gap: 6px;
}

.crm-quality-overview__copy h2 {
    color: var(--color-text-primary);
    font-size: 1.18rem;
    font-weight: 780;
}

.crm-quality-overview__copy > p:last-of-type {
    max-width: 660px;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    line-height: 1.55;
}

.crm-quality-overview__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 6px;
}

.crm-quality-overview__stats > span {
    display: grid;
    min-width: 112px;
    gap: 1px;
    border: 1px solid var(--color-border);
    border-radius: 11px;
    background: color-mix(in srgb, var(--color-bg-surface) 82%, transparent);
    padding: 8px 10px;
}

.crm-quality-overview__stats strong {
    color: var(--color-text-primary);
    font-size: 0.86rem;
}

.crm-quality-overview__stats small {
    color: var(--color-text-muted);
    font-size: 0.59rem;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-quality-guidance {
    display: grid;
    gap: 9px;
    border-left: 1px solid var(--color-border);
    padding-left: 22px;
    grid-template-columns: 27px minmax(0, 1fr);
}

.crm-quality-guidance > span {
    display: inline-flex;
    width: 25px;
    height: 25px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    font-size: 0.64rem;
    font-weight: 800;
}

.crm-quality-guidance p {
    display: grid;
    gap: 1px;
}

.crm-quality-guidance strong {
    color: var(--color-text-primary);
    font-size: 0.7rem;
}

.crm-quality-guidance small {
    color: var(--color-text-muted);
    font-size: 0.62rem;
}

.crm-quality-rule-grid {
    display: grid;
    gap: 9px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.crm-quality-rule {
    display: grid;
    min-width: 0;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--color-border);
    border-radius: 13px;
    background: var(--color-bg-surface);
    padding: 11px;
    color: var(--color-text-primary);
    grid-template-columns: 9px minmax(0, 1fr) auto;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.crm-quality-rule:hover,
.crm-quality-rule.is-active {
    border-color: color-mix(in srgb, var(--quality-rule-color, var(--color-accent)) 56%, var(--color-border));
    background: color-mix(in srgb, var(--quality-rule-color, var(--color-accent)) 7%, var(--color-bg-surface));
    transform: translateY(-1px);
}

.crm-quality-rule.is-critical { --quality-rule-color: var(--color-danger); }
.crm-quality-rule.is-review { --quality-rule-color: var(--color-accent); }
.crm-quality-rule.is-warning { --quality-rule-color: var(--color-warning); }
.crm-quality-rule.is-advisory { --quality-rule-color: var(--color-info); }

.crm-quality-rule__status {
    width: 8px;
    height: 32px;
    border-radius: 999px;
    background: var(--quality-rule-color, var(--color-accent));
}

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

.crm-quality-rule strong {
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-rule small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 0.59rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-rule em {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: color-mix(in srgb, var(--quality-rule-color, var(--color-accent)) 12%, var(--color-bg-subtle));
    color: var(--quality-rule-color, var(--color-accent));
    font-size: 0.72rem;
    font-style: normal;
    font-weight: 820;
}

.crm-quality-layout {
    display: grid;
    align-items: start;
    gap: 18px;
    grid-template-columns: minmax(0, 1.8fr) minmax(250px, 0.58fr);
}

.crm-quality-queue {
    display: grid;
    gap: 0;
    overflow: hidden;
    padding: 0 !important;
}

.crm-quality-queue__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
}

.crm-quality-queue__header > div {
    display: grid;
    gap: 3px;
}

.crm-quality-queue__header h2,
.crm-quality-workload h2 {
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 760;
}

.crm-quality-queue__header > div > p:last-child,
.crm-quality-workload > div > p:last-child {
    color: var(--color-text-muted);
    font-size: 0.65rem;
}

.crm-quality-search {
    display: grid;
    align-items: center;
    gap: 9px;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg-subtle);
    padding: 10px 14px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.crm-quality-assignment-bar {
    display: flex;
    min-height: 55px;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--color-border);
    padding: 9px 14px;
}

.crm-quality-select-all {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--color-text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
}

.crm-quality-select-all input,
.crm-quality-contact > input {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    accent-color: var(--color-accent);
}

.crm-quality-assignment-bar > span {
    color: var(--color-text-muted);
    font-size: 0.65rem;
}

.crm-quality-assignment-bar > div {
    display: flex;
    min-width: 330px;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.crm-quality-assignment-bar .bos-select {
    min-width: 190px;
    flex: 1 1 auto;
}

.crm-quality-assignment-bar .bos-select__trigger,
.crm-quality-assignment-bar select {
    min-height: 38px;
}

.crm-quality-contact-list {
    display: grid;
}

.crm-quality-contact {
    display: grid;
    min-height: 67px;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--color-border);
    padding: 8px 14px;
    grid-template-columns: 18px 34px minmax(150px, 0.75fr) minmax(180px, 1fr) minmax(120px, 0.5fr) auto;
    transition: background 140ms ease;
}

.crm-quality-contact:last-child {
    border-bottom: 0;
}

.crm-quality-contact:hover {
    background: var(--color-bg-subtle);
}

.crm-quality-contact__identity,
.crm-quality-contact__owner {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.crm-quality-contact__identity strong,
.crm-quality-contact__owner strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.7rem;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-contact__identity small,
.crm-quality-contact__owner small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 0.61rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-contact__issues {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 4px;
}

.crm-quality-contact__issues em {
    border-radius: 999px;
    background: var(--color-bg-subtle);
    padding: 4px 7px;
    color: var(--color-text-secondary);
    font-size: 0.55rem;
    font-style: normal;
    font-weight: 750;
}

.crm-quality-contact__issues em.is-critical {
    background: var(--color-danger-muted);
    color: var(--color-danger);
}

.crm-quality-contact__issues em.is-warning {
    background: var(--color-warning-muted);
    color: var(--color-warning);
}

.crm-quality-contact__issues em.is-review {
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

.crm-quality-contact__issues em.is-advisory {
    background: var(--color-info-muted);
    color: var(--color-info);
}

.crm-quality-contact > .bos-btn-ghost {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.62rem;
}

.crm-quality-aside {
    display: grid;
    gap: 14px;
}

.crm-quality-workload,
.crm-quality-policy {
    display: grid;
    gap: 14px;
}

.crm-quality-workload > div:first-child {
    display: grid;
    gap: 3px;
}

.crm-quality-workload__list {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 12px;
}

.crm-quality-workload__list > span {
    display: grid;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--color-border);
    padding: 9px;
    grid-template-columns: 30px minmax(0, 1fr) auto;
}

.crm-quality-workload__list > span:last-child {
    border-bottom: 0;
}

.crm-quality-workload__list i {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--color-accent-muted);
    color: var(--color-accent);
    font-size: 0.59rem;
    font-style: normal;
    font-weight: 800;
}

.crm-quality-workload__list .is-unassigned i {
    background: var(--color-danger-muted);
    color: var(--color-danger);
}

.crm-quality-workload__list > span > span {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.crm-quality-workload__list strong {
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-workload__list small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: 0.57rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-quality-workload__list em {
    min-width: 25px;
    border-radius: 8px;
    background: var(--color-bg-subtle);
    padding: 4px 6px;
    color: var(--color-text-secondary);
    font-size: 0.62rem;
    font-style: normal;
    font-weight: 800;
    text-align: center;
}

.crm-quality-workload__empty {
    padding: 14px;
    color: var(--color-text-muted);
    font-size: 0.65rem;
}

.crm-quality-policy ul {
    display: grid;
    gap: 9px;
}

.crm-quality-policy li {
    display: grid;
    align-items: start;
    gap: 8px;
    grid-template-columns: 24px minmax(0, 1fr);
}

.crm-quality-policy li > span {
    display: inline-flex;
    width: 23px;
    height: 23px;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: var(--color-bg-subtle);
    color: var(--color-text-secondary);
    font-size: 0.58rem;
    font-weight: 800;
}

.crm-quality-policy li p {
    display: grid;
    gap: 1px;
}

.crm-quality-policy li strong {
    color: var(--color-text-primary);
    font-size: 0.66rem;
}

.crm-quality-policy li small {
    color: var(--color-text-muted);
    font-size: 0.58rem;
}

.crm-quality-empty {
    min-height: 240px;
}

@media (max-width: 1150px) {
    .crm-quality-overview {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .crm-quality-guidance {
        border-top: 1px solid var(--color-border);
        border-left: 0;
        padding-top: 16px;
        padding-left: 0;
        grid-column: 1 / -1;
    }

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

    .crm-quality-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 767px) {
    .crm-quality-alert {
        grid-template-columns: 40px minmax(0, 1fr) 28px;
    }

    .crm-quality-alert__score {
        display: none;
    }

    .crm-quality-overview {
        justify-items: center;
        grid-template-columns: 1fr;
        text-align: center;
    }

    .crm-quality-overview__stats {
        justify-content: center;
    }

    .crm-quality-guidance {
        width: 100%;
        text-align: left;
    }

    .crm-quality-contact {
        grid-template-columns: 18px 34px minmax(0, 1fr) auto;
    }

    .crm-quality-contact__issues,
    .crm-quality-contact__owner {
        grid-column: 3 / -1;
    }

    .crm-quality-contact > .bos-btn-ghost {
        grid-column: 4;
        grid-row: 1 / span 2;
    }

    .crm-quality-assignment-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-quality-assignment-bar > div {
        width: 100%;
        min-width: 0;
        margin-left: 0;
    }
}

@media (max-width: 560px) {
    .crm-quality-rule-grid,
    .crm-quality-aside {
        grid-template-columns: 1fr;
    }

    .crm-quality-queue__header {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-quality-contact {
        grid-template-columns: 18px 32px minmax(0, 1fr);
    }

    .crm-quality-contact > .bos-btn-ghost {
        grid-column: 3;
        grid-row: auto;
        justify-self: start;
    }

    .crm-quality-contact__issues,
    .crm-quality-contact__owner {
        grid-column: 2 / -1;
    }

    .crm-quality-assignment-bar > div {
        align-items: stretch;
        flex-direction: column;
    }
}
