.history-card-v2 {
    overflow: hidden;
}

.history-legend-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: #fff;
}

.history-legend-item {
    display: grid;
    grid-template-columns: 18px auto;
    grid-template-rows: auto auto;
    column-gap: 7px;
    align-items: center;
    min-width: 0;
}

.history-legend-item > i {
    grid-row: 1 / span 2;
    width: 12px;
    height: 12px;
    border: 3px solid currentColor;
    border-radius: 50%;
    box-sizing: border-box;
}

.history-legend-item b {
    font-size: 12px;
    line-height: 1.15;
}

.history-legend-item small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.15;
}

.legend-contact { color: #267eea; }
.legend-action { color: #7047e8; }
.legend-funnel { color: #7a56d8; }
.history-legend-item small { color: var(--muted); }

.history-legend-divider {
    width: 1px;
    height: 28px;
    margin-left: auto;
    background: var(--line);
}

.history-filters-v2 {
    background: #fbfaff;
}

.history-filter-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-right: 20px;
}

.history-filter-topline .period-pills {
    min-width: 0;
    flex: 1;
}

.history-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.history-category-pill {
    min-height: 34px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: #4d5571;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.history-category-pill:hover {
    border-color: #cfc4fa;
    color: var(--violet);
}

.history-category-pill.active {
    border-color: var(--violet);
    background: var(--violet);
    color: #fff;
}

.history-timeline-v2 {
    padding: 0 20px 22px;
}

.history-day-group {
    margin-top: 16px;
}

.history-day-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 4px;
    color: #353b55;
    font-size: 13px;
    font-weight: 700;
}

.history-day-heading::after {
    height: 1px;
    flex: 1;
    background: #ece9f5;
    content: "";
}

.history-day-events {
    display: grid;
}

.history-timeline-v2 .history-event {
    --entity-color: #7047e8;
    --entity-soft: #f0ebff;
    position: relative;
    display: grid;
    grid-template-columns: 78px 14px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0 0;
}

.history-timeline-v2 .history-event.history-type-contact {
    --entity-color: #267eea;
    --entity-soft: #eaf3ff;
}

.history-timeline-v2 .history-event.history-type-action {
    --entity-color: #7047e8;
    --entity-soft: #f0ebff;
}

.history-timeline-v2 .history-event.history-type-funnel.history-funnel-business {
    --entity-color: #0c9aa6;
    --entity-soft: #e7f8fa;
}

.history-timeline-v2 .history-event.history-type-funnel.history-funnel-product,
.history-timeline-v2 .history-event.history-type-funnel:not(.history-funnel-business) {
    --entity-color: #7651db;
    --entity-soft: #f0ebff;
}

.history-timeline-v2 .history-event:not(:last-child)::after {
    position: absolute;
    z-index: 0;
    top: 27px;
    bottom: -11px;
    left: 84px;
    width: 2px;
    background: #ebe7f5;
    content: "";
}

.history-timeline-v2 .history-event-time {
    display: block;
    padding-top: 1px;
    color: #66708f;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.history-timeline-v2 .history-event-time b {
    color: #45506f;
    font-weight: 600;
}

.history-timeline-v2 .history-dot {
    position: relative;
    z-index: 1;
    width: 10px;
    height: 10px;
    margin-top: 2px;
    border: 3px solid var(--entity-soft);
    border-radius: 50%;
    background: var(--entity-color);
    box-sizing: content-box;
}

.history-timeline-v2 .history-event-card {
    min-width: 0;
    padding: 12px 14px 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
}

.history-contact-row {
    margin-bottom: 9px;
}

.history-contact-row .history-contact-link {
    font-size: 14px;
    font-weight: 700;
}

.history-primary-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
}

.history-entity-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--entity-soft);
    color: var(--entity-color);
}

.history-entity-icon svg {
    width: 18px;
    height: 18px;
}

.history-primary-copy {
    min-width: 0;
}

.history-kicker-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    min-height: 18px;
}

.history-entity-name {
    color: var(--entity-color);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.history-funnel-chip {
    min-height: 22px;
    padding: 2px 8px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.funnel-chip-product {
    background: #eee9ff;
    color: #6d49d3;
}

.funnel-chip-business {
    background: #def6f7;
    color: #087f89;
}

.funnel-chip-generic {
    background: #eef1f6;
    color: #68718a;
}

.history-event-heading {
    display: block;
    margin-top: 3px;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}

.history-status-badge {
    min-height: 24px;
    padding: 3px 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    color: #616a83;
    background: #f1f3f7;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.history-status-badge i {
    font-size: 12px;
    font-style: normal;
    line-height: 1;
}

.history-status-badge.status-planned {
    background: #eee9ff;
    color: #6d49d3;
}

.history-status-badge.status-completed {
    background: #e4f7ec;
    color: #078a45;
}

.history-status-badge.status-rescheduled {
    background: #fff0dc;
    color: #bd6700;
}

.history-status-badge.status-cancelled {
    background: #ffe9ed;
    color: #c93c55;
}

.history-status-badge.status-paused {
    background: #eef1f6;
    color: #5d667d;
}

.history-status-badge.status-resumed {
    background: #e7f8fa;
    color: #087f89;
}

.history-status-badge.status-changed,
.history-status-badge.status-created {
    background: var(--entity-soft);
    color: var(--entity-color);
}

.history-timeline-v2 .history-details {
    display: grid;
    gap: 6px;
    margin: 9px 0 0 44px;
}

.history-timeline-v2 .history-details > div {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
}

.history-timeline-v2 .history-details dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.history-timeline-v2 .history-details dd {
    margin: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

.history-open-contact {
    margin: 9px 0 0 44px;
    font-size: 13px;
}

.history-funnel-panel {
    --funnel-color: #7651db;
    --funnel-soft: #f4f0ff;
    margin: 10px 0 0 44px;
    padding: 9px 10px 8px;
    border: 1px solid #ddd5f7;
    border-radius: 9px;
    background: #faf9ff;
}

.history-funnel-panel.funnel-tone-business {
    --funnel-color: #0c9aa6;
    --funnel-soft: #e8f8fa;
    border-color: #ccebed;
    background: #f7fcfc;
}

.history-funnel-panel.funnel-tone-product {
    --funnel-color: #7651db;
    --funnel-soft: #f4f0ff;
}

.history-funnel-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.history-funnel-label {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-funnel-icon {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    flex: 0 0 22px;
    border-radius: 7px;
    background: var(--funnel-soft);
    color: var(--funnel-color);
}

.history-funnel-icon svg {
    width: 13px;
    height: 13px;
}

.history-funnel-kicker {
    color: var(--funnel-color);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.history-funnel-kind {
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--funnel-soft);
    color: var(--funnel-color);
    font-size: 10px;
    font-weight: 700;
}

.history-funnel-transition-copy,
.history-funnel-current-copy {
    min-width: 0;
    overflow: hidden;
    color: #66708a;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-funnel-transition-copy b,
.history-funnel-current-copy b {
    color: #343b56;
}

.history-funnel-transition-copy i {
    margin: 0 6px;
    color: var(--funnel-color);
    font-style: normal;
    font-weight: 700;
}

.compact-funnel-track {
    display: flex;
    align-items: flex-start;
    min-width: 0;
    height: 37px;
    margin: 6px 4px 0;
    padding: 0 4px;
}

.compact-funnel-step {
    position: relative;
    min-width: 0;
    flex: 1 1 0;
    display: flex;
    justify-content: center;
}

.compact-funnel-step::before {
    position: absolute;
    top: 6px;
    right: 50%;
    left: -50%;
    height: 2px;
    background: #dcdfea;
    content: "";
}

.compact-funnel-step:first-child::before {
    display: none;
}

.compact-funnel-step.is-reached::before {
    background: color-mix(in srgb, var(--funnel-color) 62%, white);
}

.compact-funnel-dot {
    position: relative;
    z-index: 1;
    width: 8px;
    height: 8px;
    margin-top: 3px;
    border: 2px solid #cbd0df;
    border-radius: 50%;
    background: #fff;
    box-sizing: border-box;
}

.compact-funnel-step.is-reached .compact-funnel-dot {
    border-color: color-mix(in srgb, var(--funnel-color) 62%, white);
}

.compact-funnel-step.is-old .compact-funnel-dot {
    width: 10px;
    height: 10px;
    margin-top: 2px;
    border-color: var(--funnel-color);
    background: var(--funnel-color);
}

.compact-funnel-step.is-current .compact-funnel-dot {
    width: 12px;
    height: 12px;
    margin-top: 1px;
    border: 3px solid var(--funnel-color);
    background: #fff;
    box-shadow: 0 0 0 3px var(--funnel-soft);
}

.compact-funnel-stage-label {
    position: absolute;
    top: 17px;
    max-width: 105px;
    overflow: hidden;
    color: #515a75;
    font-size: 10px;
    font-style: normal;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-funnel-step.is-current .compact-funnel-stage-label {
    color: var(--funnel-color);
}

.compact-funnel-mobile-summary {
    display: none;
}

.history-next-step {
    margin: 9px 0 0 44px;
    padding: 9px 10px;
    border: 1px solid #e0dcf0;
    border-radius: 9px;
    background: #fbfaff;
}

.history-next-label {
    color: #7256c7;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.history-next-main {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px 18px;
}

.history-next-main > strong {
    font-size: 13px;
}

.history-next-main time {
    color: #5a637d;
    font-size: 11px;
}

.history-next-details {
    margin: 6px 0 0 !important;
}

.history-no-next-step {
    margin: 8px 0 0 44px;
    color: var(--muted);
    font-size: 11px;
}

.history-details-after-funnel {
    margin-top: 7px !important;
}

@media (max-width: 1100px) {
    .history-filter-topline {
        align-items: flex-start;
        flex-direction: column;
        padding: 0 20px 10px;
    }

    .history-filter-topline .period-pills {
        padding-left: 0;
        padding-right: 0;
        padding-bottom: 0;
    }
}

@media (max-width: 720px) {
    .history-legend-strip {
        gap: 8px;
        padding: 9px 12px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .history-legend-strip::-webkit-scrollbar { display: none; }

    .history-legend-item {
        flex: 0 0 auto;
    }

    .history-legend-item small,
    .history-legend-divider {
        display: none;
    }

    .history-filter-topline {
        gap: 7px;
        padding: 0 10px 9px;
    }

    .history-filter-topline .period-pills {
        width: 100%;
        flex-wrap: nowrap;
        gap: 5px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .history-filter-topline .period-pills::-webkit-scrollbar { display: none; }

    .history-filter-topline .date-pill {
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 10px;
        font-size: 11px;
    }

    .history-category-pills {
        width: 100%;
        flex-wrap: nowrap;
        gap: 5px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .history-category-pills::-webkit-scrollbar { display: none; }

    .history-category-pill {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 0 10px;
        font-size: 11px;
    }

    .history-timeline-v2 {
        padding: 0 10px 14px;
    }

    .history-day-group {
        margin-top: 12px;
    }

    .history-day-heading {
        margin-bottom: 2px;
        font-size: 12px;
    }

    .history-timeline-v2 .history-event {
        grid-template-columns: 12px minmax(0, 1fr);
        gap: 4px 8px;
        padding-top: 9px;
    }

    .history-timeline-v2 .history-event:not(:last-child)::after {
        top: 24px;
        bottom: -10px;
        left: 5px;
    }

    .history-timeline-v2 .history-event-time {
        grid-column: 2;
        grid-row: 1;
        padding: 0;
        font-size: 10px;
        text-align: left;
    }

    .history-timeline-v2 .history-dot {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: 8px;
        height: 8px;
        margin-top: 1px;
        border-width: 2px;
    }

    .history-timeline-v2 .history-event-card {
        grid-column: 2;
        grid-row: 2;
        padding: 10px;
        border-radius: 9px;
    }

    .history-contact-row {
        margin-bottom: 7px;
    }

    .history-contact-row .history-contact-link {
        font-size: 13px;
    }

    .history-primary-row {
        grid-template-columns: 30px minmax(0, 1fr) auto;
        gap: 8px;
    }

    .history-entity-icon {
        width: 29px;
        height: 29px;
        border-radius: 8px;
    }

    .history-entity-icon svg {
        width: 16px;
        height: 16px;
    }

    .history-entity-name {
        font-size: 9px;
    }

    .history-funnel-chip {
        min-height: 18px;
        padding: 2px 6px;
        font-size: 9px;
    }

    .history-event-heading {
        margin-top: 2px;
        font-size: 14px;
    }

    .history-status-badge {
        min-height: 20px;
        padding: 2px 6px;
        gap: 3px;
        font-size: 9px;
    }

    .history-status-badge i {
        font-size: 10px;
    }

    .history-timeline-v2 .history-details,
    .history-open-contact,
    .history-funnel-panel,
    .history-next-step,
    .history-no-next-step {
        margin-left: 0;
    }

    .history-timeline-v2 .history-details {
        margin-top: 8px;
        gap: 5px;
    }

    .history-timeline-v2 .history-details > div {
        grid-template-columns: 1fr;
        gap: 1px;
    }

    .history-timeline-v2 .history-details dt {
        font-size: 10px;
    }

    .history-timeline-v2 .history-details dd {
        font-size: 12px;
    }

    .history-funnel-panel {
        margin-top: 8px;
        padding: 8px;
    }

    .history-funnel-panel-head {
        gap: 7px;
    }

    .history-funnel-transition-copy,
    .history-funnel-current-copy {
        display: none;
    }

    .compact-funnel-track {
        height: 18px;
        margin-top: 7px;
        padding: 0 2px;
    }

    .compact-funnel-stage-label {
        display: none;
    }

    .compact-funnel-mobile-summary {
        min-width: 0;
        margin-top: 4px;
        display: flex;
        align-items: center;
        gap: 6px;
        color: #67708b;
        font-size: 10px;
        white-space: nowrap;
    }

    .compact-funnel-mobile-summary span,
    .compact-funnel-mobile-summary strong {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .compact-funnel-mobile-summary i {
        flex: 0 0 auto;
        color: var(--funnel-color);
        font-style: normal;
        font-weight: 700;
    }

    .compact-funnel-mobile-summary strong {
        color: var(--funnel-color);
    }

    .history-next-main {
        gap: 3px;
        flex-direction: column;
        align-items: flex-start;
    }
}
