/* ── CRM header title ───────────────────────────────────────────────────── */
.crm-slim-header__title {
    font-size: 1.125rem !important;
    font-weight: 700;
}

/* ── CRM header left title + right actions — symmetric padding matching nice-padding ── */
.crm-header-title {
    padding-inline-start: 1.25rem;
}

.crm-header-actions {
    padding-inline-end: 1.25rem;
}

@media screen and (min-width: 50em) {
    .crm-header-title {
        padding-inline-start: 5rem;
    }

    .crm-header-actions {
        padding-inline-end: 5rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RECORD VIEW — tabbed view/edit interface
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Record header ──────────────────────────────────────────────────────── */

.crm-record-header {
    background: var(--w-color-surface-page, #fff);
    padding: 1rem 0;
    margin-top: 2rem;
}

.crm-record-header__avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--w-color-primary, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
}

.crm-record-header__name {
    font-size: 1.6rem;
    line-height: 1.2;
}

/* ── Record badges ──────────────────────────────────────────────────────── */

.crm-record-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.crm-record-badge--stub {
    background: #fef3c7;
    color: #b45309;
}

.crm-record-badge--inactive {
    background: #f3f4f6;
    color: #6b7280;
}

/* ── Completeness indicator ─────────────────────────────────────────────── */

.crm-completeness {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crm-completeness__bar {
    width: 16rem;
    height: 0.75rem;
    background: var(--w-color-border-furniture, #e5e7eb);
    border-radius: 999px;
    overflow: hidden;
}

.crm-completeness__fill {
    height: 100%;
    background: var(--w-color-primary, #2563eb);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.crm-completeness__label {
    font-size: 0.85rem;
    color: var(--w-color-text-meta, #6b7280);
}

/* ── Tab navigation — uses Wagtail's w-tabs classes ─────────────────────── */

/* Wagtail applies margin-bottom: 2rem to .w-tabs__wrapper; neutralise it so
   the stage bar sits evenly between the tab list and the panel content. */
.crm-record .w-tabs__wrapper {
    margin-bottom: 0;
}

/* ── Overview quadrant grid ──────────────────────────────────────────────── */

/* Flat 2×2 grid — each field group is a direct child so CSS grid can equalise
   row heights across both columns. */
.crm-overview-grid {
    align-items: stretch;
}

.crm-field-group--card {
    background: #f9fafb;
    border-radius: 0.375rem;
    padding: 1rem 1.75rem;
}

/* Social (row 2, col 2) — no background, but matching x-padding for alignment */
.crm-field-group--aside {
    padding-inline: 1.75rem;
}

/* ── Field display primitives ───────────────────────────────────────────── */

.crm-field-group {
    margin-bottom: 1.5rem;
}

.crm-field-group__heading {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    margin: 0 0 0.75rem;
}

.crm-field-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 1rem;
}

.crm-field-row__label {
    color: var(--w-color-text-meta, #6b7280);
    min-width: 6rem;
    flex-shrink: 0;
}

.crm-field-row__value {
    color: var(--w-color-text-label, #111827);
}

.crm-field-row__value a {
    color: var(--w-color-primary, #2563eb);
}

.crm-field-row__value a:hover {
    text-decoration: underline;
}

.crm-empty-state {
    font-size: 0.875rem;
    color: var(--w-color-text-meta, #6b7280);
}

/* ── Inline address display ─────────────────────────────────────────────── */

.crm-places-wrapper {
    margin: 1.25rem 0;
    border-radius: 0.3125rem;
    background-color: var(--w-color-surface-field);
    border: 1px solid var(--w-color-border-field-default);
}

.crm-address {
    font-size: 1rem;
    font-style: normal !important;
    color: var(--w-color-text-label, #111827);
    line-height: 1.6;
}

/* ── Tag chips ──────────────────────────────────────────────────────────── */

.crm-tag {
    display: inline-block;
    background: var(--w-color-grey-900, #1a1a1a);
    border: 1px solid var(--w-color-grey-900, #1a1a1a);
    border-radius: 999px;
    font-size: 1rem;
    padding: 0.3rem 1rem;
    margin: 0.15rem 0.2rem 0.15rem 0;
    color: #ffffff;
}

/* ── crm record panel ─────────────────────────────────────────────────────── */

.crm-hidden-panel-item {
    display: none !important;
}

/* ── Stage path bar ──────────────────────────────────────────────────────── */

.crm-stage-bar {
    background: var(--w-color-surface-page, #fff);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    flex-wrap: wrap;
}

.crm-stage-bar__steps {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex: 1;
}

.crm-stage-bar__step {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: 1px solid var(--w-color-border-furniture, #e5e7eb);
    border-radius: 999px;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    font-size: 0.8125rem;
    color: var(--w-color-text-meta, #6b7280);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.crm-stage-bar__step:hover {
    border-color: var(--w-color-primary, #2563eb);
    color: var(--w-color-primary, #2563eb);
}

.crm-stage-bar__step--past {
    color: var(--w-color-text-label, #111827);
    border-color: var(--w-color-border-furniture, #e5e7eb);
}

.crm-stage-bar__step--active {
    background: var(--w-color-text-label, #111827);
    border-color: var(--w-color-text-label, #111827);
    color: #fff;
    font-weight: 600;
    cursor: default;
}

.crm-stage-bar__step--active:hover {
    background: var(--w-color-text-label, #111827);
    border-color: var(--w-color-text-label, #111827);
    color: #fff;
}

.crm-stage-bar__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--w-color-border-furniture, #e5e7eb);
    color: var(--w-color-text-meta, #6b7280);
    font-size: 0.625rem;
    font-weight: 700;
    flex-shrink: 0;
}

.crm-stage-bar__icon::before {
    content: attr(data-index);
}

.crm-stage-bar__step--past .crm-stage-bar__icon {
    background: var(--w-color-text-label, #111827);
    color: #fff;
}

.crm-stage-bar__step--past .crm-stage-bar__icon::before {
    content: "✓";
}

.crm-stage-bar__step--active .crm-stage-bar__icon {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.crm-stage-bar__actions {
    margin-left: auto;
    flex-shrink: 0;
}

.crm-stage-bar__actions form {
    margin: 0;
}

.crm-stage-bar__dormancy-btn {
    background: none;
    border: 1px solid var(--w-color-border-furniture, #e5e7eb);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    cursor: pointer;
    color: var(--w-color-text-meta, #6b7280);
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.crm-stage-bar__dormancy-btn:hover {
    border-color: var(--w-color-text-label, #111827);
    color: var(--w-color-text-label, #111827);
}

.crm-stage-bar__dormancy-btn--reactivate {
    border-color: var(--w-color-primary, #2563eb);
    color: var(--w-color-primary, #2563eb);
}

/* ── Stage change dialog ─────────────────────────────────────────────────── */

.crm-stage-bar__dialog {
    border: none;
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 420px;
    width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    background: var(--w-color-surface-page, #fff);
}

.crm-stage-bar__dialog textarea {
    width: 100%;
    min-height: 5rem;
    margin: 0.75rem 0;
    padding: 0.5rem;
    border: 1px solid var(--w-color-border-field-default, #d1d5db);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    resize: vertical;
    box-sizing: border-box;
}

.crm-stage-bar__dialog-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ── Timeline ────────────────────────────────────────────────────────────── */

.crm-timeline {
    padding: 1.5rem 0;
    max-width: 48rem;
}

.crm-timeline__list {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Vertical connector line */
.crm-timeline__list::before {
    content: "";
    position: absolute;
    top: 0.75rem;
    bottom: 0;
    left: 0.9375rem; /* centres on the 1.875rem node */
    width: 2px;
    background: var(--w-color-border-furniture, #e5e7eb);
}

.crm-timeline__entry {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.75rem;
    position: relative;
}

.crm-timeline__entry:last-child {
    padding-bottom: 0;
}

/* ── Node ── */

.crm-timeline__node {
    flex-shrink: 0;
    z-index: 1;
}

.crm-timeline__node-icon {
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--w-color-primary, #2563eb);
    color: #fff;
}

.crm-timeline__node-icon svg {
    width: 0.875rem;
    height: 0.875rem;
}

.crm-timeline__entry--dormant .crm-timeline__node-icon {
    background: #d97706;
}

.crm-timeline__entry--reactivated .crm-timeline__node-icon {
    background: #16a34a;
}

/* ── Body ── */

.crm-timeline__body {
    padding-top: 0.2rem;
    min-width: 0;
}

.crm-timeline__description {
    font-size: 0.9375rem;
    color: var(--w-color-text-label, #111827);
    margin: 0 0 0.25rem;
    line-height: 1.4;
}

.crm-timeline__arrow {
    margin: 0 0.3rem;
    color: var(--w-color-text-meta, #6b7280);
}

.crm-timeline__meta {
    font-size: 0.8125rem;
    color: var(--w-color-text-meta, #6b7280);
    margin: 0;
}

.crm-timeline__reason {
    margin: 0.6rem 0 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--w-color-border-furniture, #e5e7eb);
    font-size: 0.875rem;
    color: var(--w-color-text-meta, #6b7280);
    font-style: italic;
}

.crm-timeline__empty {
    font-size: 0.875rem;
    color: var(--w-color-text-meta, #6b7280);
    text-align: center;
    padding: 3rem 0;
}


.crm-tab-panel {
    padding-top: 1.5rem;
}
