/* Deal form loading overlay */
.deal-form-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    border-radius: 0;
    gap: 16px;
}

.deal-form-loading-overlay .loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.deal-form-loading-overlay .loading-text {
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Deal form modal — Velocity Enterprise */

.modal-content.modal-deal {
    display: flex;
    flex-direction: column;
    width: min(96vw, 1400px);
    max-width: 1400px;
    max-height: 92vh;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.modal[hidden] {
    display: none !important;
}

.deal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.deal-form-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: var(--space-2) var(--space-3);
}

.deal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: var(--space-3);
    align-items: start;
}

.deal-metrics-grid .form-group.full-width {
    grid-column: 1 / -1;
}

@media (min-width: 640px) {
    .deal-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .deal-metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.deal-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.deal-form-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    flex: 1;
}

.deal-form-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-subtle);
    color: var(--brand-primary);
    flex-shrink: 0;
}

.deal-form-title {
    margin: 0;
    font-size: var(--font-title);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
}

.deal-stage-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    flex-shrink: 0;
}

.deal-revenue-completion {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    line-height: 1.3;
    flex-shrink: 0;
    white-space: nowrap;
    background: var(--status-warning-subtle, #fef3c7);
    color: var(--status-warning-strong, #92400e);
}

.deal-revenue-completion.is-complete {
    background: #dcfce7;
    color: #166534;
}

.deal-revenue-completion.hidden {
    display: none;
}

.deal-form-tabs {
    display: flex;
    gap: 0;
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.deal-form-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-1) var(--space-2);
    margin-bottom: -1px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-label);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}

.deal-form-tab svg {
    flex-shrink: 0;
    opacity: 0.75;
}

.deal-form-tab:hover {
    color: var(--text-primary);
}

.deal-form-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.deal-form-tab.active svg {
    opacity: 1;
}

.deal-form-tab.has-error::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-danger);
}

.deal-tab-panel {
    padding: var(--space-3) 0;
}

.deal-tab-panel.hidden {
    display: none;
}

.deal-form-section-label {
    display: block;
    margin: 0 0 var(--space-1);
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* ── Form Grid (one field per row — label + its input share the row) ── */
.deal-form-grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
}

/* Label + field on the same row, with a fixed label column so every field's
   control area (input/select + any adorners/buttons) lines up to the same
   width across the whole stepper. */
.deal-form-grid-1 {
    --deal-field-label-width: 140px;
}

.deal-form .deal-form-grid-1 .form-group {
    display: grid;
    grid-template-columns: var(--deal-field-label-width) minmax(0, 1fr);
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
}

.deal-form .deal-form-grid-1 .form-group.full-width {
    grid-column: 1 / -1;
}

.deal-form-inline-pair {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

@media (max-width: 768px) {
    .deal-form-inline-pair {
        grid-template-columns: 1fr;
    }
}

.deal-form .deal-form-inline-pair .form-group {
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 8px;
    min-width: 0;
}

.deal-form .deal-form-inline-pair .form-group > label {
    white-space: nowrap;
}

.deal-form .deal-form-inline-pair .form-group .form-input,
.deal-form .deal-form-inline-pair .form-group input[type="date"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.deal-form .deal-form-grid-1 .form-group > label {
    grid-column: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.deal-form .deal-form-grid-1 .form-group .form-input,
.deal-form .deal-form-grid-1 .form-group select,
.deal-form .deal-form-grid-1 .form-group textarea,
.deal-form .deal-form-grid-1 .form-group .input-adorned,
.deal-form .deal-form-grid-1 .form-group .select-with-icon,
.deal-form .deal-form-grid-1 .form-group .form-input-wrap,
.deal-form .deal-form-grid-1 .form-group .probability-control {
    grid-column: 2;
    width: 100%;
    min-width: 0;
}

/* Fields whose control is tall/multi-line: top-align the label instead of centering it */
.deal-form .deal-form-grid-1 .form-group:has(> textarea) {
    align-items: start;
}
.deal-form .deal-form-grid-1 .form-group:has(> textarea) > label {
    padding-top: 10px;
}

.deal-form .deal-form-grid-1 .form-group .field-error,
.deal-form .deal-form-grid-1 .form-group .field-warning {
    grid-column: 2;
    margin-top: 2px;
}
.deal-form .deal-form-grid-1 .form-group .field-hint {
    grid-column: 2;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}
.deal-form .deal-form-grid-1 .form-group .field-hint.field-hint-block {
    margin-top: 2px;
    white-space: normal;
    line-height: 1.35;
}

/* Deal Details layout: one shared two-column field grid.
   Single fields span both columns; only approved paired rows stay 50/50. */
#dealDetailsContent .deal-form-grid-1 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, calc(50% - 8px)));
    column-gap: 16px;
    row-gap: 20px;
    align-items: start;
}

#dealDetailsContent .deal-form-grid-1 > .form-group,
#dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair {
    grid-column: 1 / -1;
}

#dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, calc(50% - 8px)));
    gap: 16px;
}

#dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair.inline-pair-name-date {
    grid-template-columns: 80fr 20fr;
}

#dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair.inline-pair-currency-amount {
    grid-template-columns: 150px minmax(0, 1fr);
}

#dealDetailsContent .deal-form-grid-1 .form-group {
    display: block;
    width: 100%;
    min-width: 0;
}

#dealDetailsContent .deal-form-grid-1 .form-group > label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    white-space: normal;
}

#dealDetailsContent .deal-form-grid-1 .form-group .form-input,
#dealDetailsContent .deal-form-grid-1 .form-group select,
#dealDetailsContent .deal-form-grid-1 .form-group textarea,
#dealDetailsContent .deal-form-grid-1 .form-group .input-adorned,
#dealDetailsContent .deal-form-grid-1 .form-group .select-with-icon,
#dealDetailsContent .deal-form-grid-1 .form-group .custom-select,
#dealDetailsContent .deal-form-grid-1 .form-group .form-input-wrap,
#dealDetailsContent .deal-form-grid-1 .form-group .custom-date-field,
#dealDetailsContent .deal-form-grid-1 .form-group .probability-control {
    width: 100%;
    min-width: 0;
}

/* Keep + / edit buttons inline with the select (same as Account / Sales Rep) */
#dealDetailsContent .deal-form-grid-1 .form-group .select-with-icon.quick-create-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#dealDetailsContent .deal-form-grid-1 .form-group .select-with-icon.quick-create-wrapper > .custom-select {
    width: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    grid-column: auto;
}

#dealDetailsContent .deal-form-grid-1 .form-group .select-with-icon.quick-create-wrapper > .quick-create-btn-group,
#dealDetailsContent .deal-form-grid-1 .form-group .select-with-icon.quick-create-wrapper > .quick-create-btn {
    flex: 0 0 auto;
}

#dealDetailsContent .deal-form-grid-1 .form-group .form-input,
#dealDetailsContent .deal-form-grid-1 .form-group select,
#dealDetailsContent .deal-form-grid-1 .form-group .input-adorned,
#dealDetailsContent .deal-form-grid-1 .form-group .custom-select-trigger {
    min-height: 44px;
}

#dealDetailsContent .deal-form-grid-1 .field-error,
#dealDetailsContent .deal-form-grid-1 .field-warning,
#dealDetailsContent .deal-form-grid-1 .field-hint {
    margin-top: 6px;
}

@media (max-width: 768px) {
    #dealDetailsContent .deal-form-grid-1,
    #dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair {
        grid-template-columns: 1fr;
    }
    #dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair.inline-pair-name-date,
    #dealDetailsContent .deal-form-grid-1 > .deal-form-inline-pair.inline-pair-currency-amount {
        grid-template-columns: 1fr;
    }
}

/* Revenue & Billing layout — labels above inputs, consistent widths like Details */
#sectionRevenueCard .deal-form-grid-1 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, calc(50% - 8px)));
    column-gap: 16px;
    row-gap: 20px;
    align-items: start;
}

#sectionRevenueCard .deal-form-grid-1 > .form-group,
#sectionRevenueCard .deal-form-grid-1 > .deal-form-inline-pair {
    grid-column: 1 / -1;
}

#sectionRevenueCard .deal-form-grid-1 > .deal-form-inline-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, calc(50% - 8px)));
    gap: 16px;
}

#sectionRevenueCard .deal-form-grid-1 .form-group {
    display: block;
    min-width: 0;
}

#sectionRevenueCard .deal-form-grid-1 .form-group > label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    white-space: normal;
}

#sectionRevenueCard .deal-form-grid-1 .form-group .form-input,
#sectionRevenueCard .deal-form-grid-1 .form-group select,
#sectionRevenueCard .deal-form-grid-1 .form-group textarea,
#sectionRevenueCard .deal-form-grid-1 .form-group .input-adorned,
#sectionRevenueCard .deal-form-grid-1 .form-group .select-with-icon,
#sectionRevenueCard .deal-form-grid-1 .form-group .custom-select,
#sectionRevenueCard .deal-form-grid-1 .form-group .form-input-wrap,
#sectionRevenueCard .deal-form-grid-1 .form-group .probability-control {
    width: 100%;
    min-width: 0;
}

#sectionRevenueCard .deal-form-grid-1 .form-group .form-input,
#sectionRevenueCard .deal-form-grid-1 .form-group select,
#sectionRevenueCard .deal-form-grid-1 .form-group .input-adorned,
#sectionRevenueCard .deal-form-grid-1 .form-group .custom-select-trigger {
    min-height: 44px;
}

#sectionRevenueCard .deal-form-grid-1 .field-error,
#sectionRevenueCard .deal-form-grid-1 .field-warning,
#sectionRevenueCard .deal-form-grid-1 .field-hint {
    margin-top: 6px;
}

#sectionRevenueCard .deal-form-grid-1 .form-group.form-group-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    min-height: 44px;
}

#sectionRevenueCard .deal-form-grid-1 .form-group.form-group-checkbox label {
    width: auto;
    min-width: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    margin: 0;
}

@media (max-width: 768px) {
    #sectionRevenueCard .deal-form-grid-1,
    #sectionRevenueCard .deal-form-grid-1 > .deal-form-inline-pair {
        grid-template-columns: 1fr;
    }
}

#sectionRevenueCard .toggle-row {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 0;
    grid-column: 1 / -1;
}

#sectionRevenueCard .toggle-row > span:first-child {
    display: none;
}

#sectionRevenueCard .input-inline-hint {
    display: flex;
    align-items: center;
    gap: 8px;
}

#sectionRevenueCard .input-inline-hint .form-input {
    width: auto;
    flex: 1;
    min-width: 0;
}

#sectionRevenueCard .input-inline-hint #dealPaymentCountUnit {
    display: inline-block;
    margin: 0;
    white-space: nowrap;
    line-height: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Override for form-group-checkbox inside grid-1: no fixed-width label */
.deal-form .deal-form-grid-1 .form-group.form-group-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    min-height: 44px;
}
.deal-form .deal-form-grid-1 .form-group.form-group-checkbox label {
    width: auto;
    min-width: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    margin: 0;
}
.deal-form .deal-form-grid-1 .form-group.form-group-checkbox .field-error,
.deal-form .deal-form-grid-1 .form-group.form-group-checkbox .field-hint {
    margin-left: 0;
}

/* Hint text below inputs in grid-1 */
/* Align commission eligibility checkbox with input fields (col 2) */
.deal-form .commission-eligibility-check {
    padding-left: min(calc(var(--deal-field-label-width, 168px) + var(--space-2, 12px)), 28%);
    margin-bottom: 14px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.deal-form .deal-form-grid-1 .form-group .field-hint-inline,
.deal-form .deal-form-grid-1 .form-group #dealPaymentCountUnit {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Input wrapper with action buttons */
.form-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-input-wrap .form-input,
.form-input-wrap select {
    flex: 1;
}

.input-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.input-action-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: var(--brand-primary-light, rgba(37, 99, 235, 0.06));
}

.input-action-btn svg {
    display: block;
}

.deal-form-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

@media (min-width: 640px) {
    .deal-form-grid-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .deal-form-grid-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

.deal-form-grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

@media (min-width: 640px) {
    .deal-form-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1200px) {
    .deal-form-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

.deal-form-grid-4 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

@media (min-width: 640px) {
    .deal-form-grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .deal-form-grid-4 {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

.deal-form-grid-full {
    grid-column: 1 / -1;
}

/* ── Form Field Spacing ── */
.deal-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
}

.deal-form .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0;
}

.deal-form .form-group .form-input,
.deal-form .form-group select,
.deal-form .form-group .input-adorned,
.deal-form .form-group .custom-select,
.deal-form .form-group .custom-select-trigger {
    min-height: 44px;
}

.deal-form .form-group .form-input,
.deal-form .form-group select,
.deal-form .form-group .custom-select,
.deal-form .form-group .custom-select-trigger,
.deal-form .form-group .custom-select-trigger-text,
.deal-form .form-group .custom-select-option {
    font-size: var(--font-label);
    font-family: inherit;
    font-weight: var(--font-weight-normal);
    line-height: 1.4;
}

/* ── Section Spacing ── */
.deal-form-section {
    margin-bottom: 24px;
}

.deal-form-section:last-child {
    margin-bottom: 0;
}

.deal-form-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.deal-form-section-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.deal-form-section-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.deal-form-section-fields .deal-form-grid-2,
.deal-form-section-fields .deal-form-grid-3,
.deal-form-section-fields .deal-form-grid-4 {
    margin-bottom: 0;
}

/* ── Field Group Spacing ── */
.deal-form-field-group {
    margin-bottom: 24px;
}

.deal-form-field-group:last-child {
    margin-bottom: 0;
}

.deal-form-field-group-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ── Amount Field Alignment ── */
.deal-form .amount-field {
    position: relative;
}

.deal-form .amount-field .input-adorned {
    min-height: 44px;
}

.deal-form .amount-field .input-prefix,
.deal-form .amount-field .input-suffix {
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-muted);
    padding: 0 12px;
    font-size: 14px;
}

.deal-form .amount-field input {
    font-weight: 600;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

/* ── Readonly / auto-synced fields (e.g. Contract Value mirrors Deal Amount) ── */
.deal-form input[readonly].form-input,
.deal-form .input-adorned:has(input[readonly]) {
    background: var(--surface-muted);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.deal-form .input-adorned:has(input[readonly]) input[readonly] {
    background: transparent;
}

.deal-form input[readonly].form-input:focus,
.deal-form input[readonly].form-input:focus-visible {
    outline: none;
    box-shadow: none;
}

/* ── Table Alignment ── */
.deal-form-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 16px;
}

.deal-form-table thead {
    background: var(--surface-background);
    border-bottom: 2px solid var(--border-default);
}

.deal-form-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.deal-form-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.deal-form-table tbody tr:last-child td {
    border-bottom: none;
}

.deal-form-table tbody tr:hover {
    background: var(--surface-background);
}

/* ── Contact Table Specific ── */
.contact-table-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}

.contact-table-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface-background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-default);
}

.contact-table-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
    transition: background 0.15s;
}

.contact-table-row:last-child {
    border-bottom: none;
}

.contact-table-row:hover {
    background: var(--surface-background);
}

@media (max-width: 1024px) {
    .contact-table-grid,
    .contact-table-header,
    .contact-table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ── Commission Split Table ── */
.commission-split-grid {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}

.commission-split-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface-background);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-default);
}

.commission-split-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}

.commission-split-row:last-child {
    border-bottom: none;
}

@media (max-width: 1024px) {
    .commission-split-grid,
    .commission-split-header,
    .commission-split-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ── Responsive Adjustments ── */
@media (max-width: 640px) {
    .deal-form-grid-2,
    .deal-form-grid-3,
    .deal-form-grid-4 {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .deal-form-section {
        margin-bottom: 20px;
    }

    .deal-form-field-group {
        margin-bottom: 20px;
    }

    .deal-form .form-group .form-input,
    .deal-form .form-group select,
    .deal-form .form-group .input-adorned {
        min-height: 44px;
    }
}

.deal-form-section-hint {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.deal-form-section-hint::before,
.deal-form-section-hint::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

#dealLostReasonGroup {
    display: none;
}

#dealLostReasonGroup.is-stage-lost {
    display: flex;
}
#dealLostReasonGroup.is-stage-lost label {
    color: var(--status-danger, #dc2626);
}

.deal-form-grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
    align-items: start;
}

@media (min-width: 640px) {
    .deal-form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .deal-form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.deal-metrics-box {
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--surface-background);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
}

.deal-metrics-box .deal-metrics-grid {
    align-items: start;
}

.deal-metrics-box .deal-metrics-grid > .form-group {
    min-width: 0;
    align-self: start;
}

.deal-metrics-box .form-group {
    min-width: 0;
}

.probability-control {
    display: grid;
    gap: var(--space-3);
}

.probability-slider {
    width: 100%;
    min-width: 0;
    height: 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    accent-color: var(--brand-primary);
    cursor: pointer;
}

.probability-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: 2px solid var(--surface-background);
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}

.probability-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: 2px solid var(--surface-background);
}

.probability-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.probability-number-wrap {
    width: min(8rem, 100%);
}

.probability-number-wrap input {
    width: 100%;
}

.probability-value-label {
    color: var(--text-secondary);
    font-size: var(--font-label);
    white-space: nowrap;
    margin-left: auto;
    min-width: 4rem;
    text-align: right;
}

.deal-metrics-box .field-hint {
    margin: 0;
}

.deal-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.deal-form .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.deal-form .form-group.full-width {
    grid-column: 1 / -1;
}

.deal-form .form-group.is-invalid input,
.deal-form .form-group.is-invalid select,
.deal-form .form-group.is-invalid textarea,
.deal-form .form-group.is-invalid .input-adorned,
.deal-form .form-group.is-invalid .custom-select .custom-select-trigger {
    border-color: var(--status-danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.field-error {
    font-size: var(--font-caption);
    color: var(--status-danger);
    line-height: 1.35;
}

.field-warning {
    font-size: var(--font-caption);
    color: var(--status-warning);
    line-height: 1.35;
}

.input-adorned {
    display: flex;
    align-items: center;
    min-height: var(--control-height);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    overflow: hidden;
}

.input-adorned:focus-within {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
}

.input-adorned:hover:not(:focus-within):not(:has(input[readonly])):not(:has(input:disabled)) {
    border-color: var(--brand-primary);
}

.input-adorned .input-prefix,
.input-adorned .input-suffix {
    padding: 0 var(--space-2);
    color: var(--text-secondary);
    font-size: var(--font-label);
    font-weight: var(--font-weight-medium);
    flex-shrink: 0;
    background: var(--surface-background);
}

.retainer-combined-input {
    padding-left: 0;
}

.retainer-mode-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 var(--space-2);
    border-right: 1px solid var(--border-default);
    background: var(--surface-background);
    flex-shrink: 0;
    min-height: calc(var(--control-height) - 2px);
}

.retainer-mode-toggle-label {
    font-size: var(--font-label);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    line-height: 1;
    user-select: none;
    transition: color 0.15s, font-weight 0.15s;
}

.retainer-mode-dollar {
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

.is-percent-mode .retainer-mode-dollar {
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

.is-percent-mode .retainer-mode-percent {
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

.retainer-percent-toggle .toggle-slider {
    width: 28px;
    height: 16px;
}

.retainer-percent-toggle .toggle-slider::after {
    width: 12px;
    height: 12px;
    top: 2px;
    left: 2px;
}

.retainer-percent-toggle input:checked + .toggle-slider::after {
    transform: translateX(12px);
}

.retainer-combined-input .input-prefix,
.retainer-combined-input .input-suffix {
    border-left: none;
}

.os-retainer-tag {
    font-size: 0.68rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    margin-top: 3px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.os-retainer-full {
    background: color-mix(in srgb, var(--status-success) 14%, transparent);
    color: var(--status-success);
}

.os-retainer-split {
    background: color-mix(in srgb, var(--status-warning) 14%, transparent);
    color: var(--status-warning);
}

.ongoing-schedule-row.has-retainer {
    border-left: 3px solid var(--status-success);
}

.os-retainer-summary {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.os-retainer-summary strong {
    color: var(--text-primary);
}

.sidebar-retainer-value {
    color: var(--status-success) !important;
    font-weight: var(--font-weight-bold);
}

.sidebar-invoice-tag {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: var(--font-weight-semibold);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    margin-left: 4px;
    vertical-align: middle;
}

.sidebar-invoice-tag.tag-retainer {
    background: color-mix(in srgb, var(--status-success) 14%, transparent);
    color: var(--status-success);
}

.sidebar-invoice-tag.tag-partial {
    background: color-mix(in srgb, var(--status-warning) 14%, transparent);
    color: var(--status-warning);
}

.sidebar-invoice-row.has-retainer-inv {
    border-left: 2px solid var(--status-success);
    padding-left: 6px;
}

.input-adorned.is-readonly {
    background: var(--surface-background);
    cursor: default;
}

.input-adorned.is-readonly input[readonly] {
    color: var(--text-primary);
    cursor: default;
}

.input-adorned input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    min-height: calc(var(--control-height) - 2px);
    padding: 0 var(--space-2);
    font-size: var(--font-label);
    outline: none;
    box-shadow: none;
}

.input-adorned input.form-input:focus,
.input-adorned input.form-input:focus-visible {
    outline: none;
    border: none;
    box-shadow: none;
}

.input-with-icon {
    position: relative;
}

.input-with-icon .input-icon {
    position: absolute;
    left: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon:has(.input-icon) select,
.input-with-icon:has(.input-icon) input {
    padding-left: calc(var(--space-2) + 22px);
}

.select-with-icon {
    position: relative;
}

.select-with-icon .input-icon {
    position: absolute;
    left: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
    display: flex;
    align-items: center;
}

.select-with-icon:has(> .input-icon) select {
    padding-left: calc(var(--space-2) + 22px);
}

.select-with-icon.quick-create-wrapper select,
.select-with-icon.quick-create-wrapper .form-input {
    padding-left: var(--space-2);
}

.deal-form select.form-input,
.deal-form input.form-input,
.deal-form textarea.form-input,
.deal-form .input-adorned,
.deal-form .select-with-icon select,
.deal-form .input-with-icon input {
    width: 100%;
    min-height: 44px;
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.deal-form input[type="date"].form-input,
.deal-form input[type="date"] {
    padding-left: 12px;
    padding-right: 10px;
}

.deal-form input[type="date"]::-webkit-datetime-edit {
    padding-left: 0;
}

.deal-form input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
}

.deal-form select.form-input {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

.deal-form select.form-input,
.deal-form .select-with-icon select {
    cursor: pointer;
    appearance: auto;
}

.deal-form .field-hint {
    margin: 0;
    font-size: var(--font-caption);
    color: var(--text-secondary);
    line-height: 1.35;
}

.deal-contact-roles-section {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

.deal-contact-roles-section.is-invalid {
    border: 1px solid var(--status-danger, #ef4444);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    background: rgba(239, 68, 68, 0.04);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.deal-contact-roles-section.is-invalid .field-error {
    display: block;
    color: var(--status-danger, #ef4444);
    margin-top: var(--space-2);
}

.deal-contact-roles-section.field-highlight {
    animation: deal-field-pulse 1.2s ease;
}

@keyframes deal-field-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.22); }
}

.deal-contact-roles-section .field-hint {
    margin: calc(-1 * var(--space-1)) 0 var(--space-2);
}

.deal-form .commission-split-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 4.5rem auto;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}

.account-modal-form .account-commission-split-row {
    grid-template-columns: minmax(0, 0.72fr) minmax(0, 0.82fr) minmax(0, 1.85fr) 4.75rem auto;
}

.deal-form .commission-split-row .split-pct {
    width: 100%;
}

.deal-form .deal-contact-role-row {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto auto;
    align-items: start;
}

.deal-form .deal-contact-role-row label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-caption);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    white-space: nowrap;
    margin: 0;
    min-height: var(--control-height, 40px);
}

.deal-form .cr-contact-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.deal-form .cr-contact-meta {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-height: 20px;
}

.deal-form .cr-contact-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm, 6px);
    background: var(--surface-elevated, #fff);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.deal-form .cr-contact-info-btn:hover:not(:disabled) {
    color: var(--brand-primary, #2563eb);
    border-color: var(--brand-primary, #2563eb);
}

.deal-form .cr-contact-info-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.deal-form .cr-contact-info-btn[aria-expanded="true"] {
    color: var(--brand-primary, #2563eb);
    border-color: var(--brand-primary, #2563eb);
    background: color-mix(in srgb, var(--brand-primary, #2563eb) 8%, transparent);
}

.deal-form .cr-contact-details {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-secondary);
}

.deal-form .cr-contact-details[hidden] {
    display: none;
}

.deal-form .cr-contact-details .cr-contact-detail-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-form .cr-contact-details .cr-contact-detail-empty {
    color: var(--text-muted);
    font-style: italic;
}

.deal-form .deal-contact-role-row .cr-remove {
    min-height: var(--control-height, 40px);
    display: inline-flex;
    align-items: center;
}

.deal-form .commission-split-row > span {
    font-size: var(--font-caption);
    color: var(--text-secondary);
}

.deal-form-notes {
    margin-top: var(--space-3);
}

.deal-tab-hint {
    font-size: var(--font-label);
    color: var(--text-secondary);
    margin: 0 0 var(--space-2);
    padding: var(--space-2);
    background: var(--surface-background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.deal-form-footer {
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border-default);
    background: var(--surface-elevated);
}

.deal-form-footer-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.deal-form-footer-row .deal-form-actions {
    margin-left: auto;
}

.deal-form-footer-left {
    flex: 0 0 auto;
}

.deal-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--status-danger, #ef4444);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.deal-delete-btn:hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: var(--status-danger, #ef4444);
}

.deal-form-actions .btn-primary {
    min-width: 160px;
    min-height: 44px;
    padding: 0 var(--space-4);
}

.deal-form-actions .btn:not(.btn-primary) {
    opacity: 0.85;
}

.deal-form-actions .btn-secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.field-error {
    display: block;
    margin-top: 0.25rem;
}

.field-error[hidden] {
    display: none;
    margin-top: 0;
}

.deal-form-banner {
    margin-bottom: var(--space-2);
    padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--font-label);
    line-height: 1.4;
}

.deal-form-banner.hidden {
    display: none;
}

.deal-form-banner.is-error {
    background: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.deal-form-banner.is-success {
    background: #F0FDF4;
    color: #166534;
    border: 1px solid #BBF7D0;
}

.deal-form-meta {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    line-height: 1.4;
}

.deal-form-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.deal-form-actions .btn-primary {
    min-height: var(--control-height-lg);
}

.deal-form .form-section {
    border: none;
    padding: 0;
    margin: 0 0 var(--space-3);
}

.deal-form .form-section legend {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

@media (max-width: 640px) {
    .deal-form-grid-2,
    .deal-form-grid-3,
    .deal-metrics-grid {
        grid-template-columns: 1fr;
    }

    .deal-form .commission-split-row,
    .deal-form .deal-contact-role-row {
        grid-template-columns: 1fr;
    }

    .deal-form-actions {
        width: 100%;
    }

    .deal-form-actions .btn {
        flex: 1;
        min-height: var(--touch-target-min);
    }
}

.account-360-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: var(--surface-muted, #f5f5f7);
    border-bottom: 1px solid var(--border-subtle, #e5e5ea);
    font-size: var(--font-caption);
}

.account-rating-badge {
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: capitalize;
    font-weight: var(--font-weight-semibold);
}

.account-rating-badge.rating-hot { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }
.account-rating-badge.rating-warm { background: rgba(245, 158, 11, 0.12); color: #b45309; border: 1px solid rgba(245, 158, 11, 0.35); }
.account-rating-badge.rating-cold { background: var(--surface-input); color: var(--text-secondary); }

.deal-next-step-bar {
    padding: var(--space-1) var(--space-3) var(--space-1);
    border-bottom: 1px solid var(--border-subtle, #e5e5ea);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.deal-next-step-bar label {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
}

.deal-next-step-row {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.deal-next-step-row .form-input {
    flex: 1;
    min-width: 0;
}

.deal-next-step-date {
    width: 140px;
    flex-shrink: 0;
}

.deal-next-step-row .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}

.deal-next-step-row .btn-icon:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    background: var(--brand-primary-subtle);
}

.deal-next-step-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: var(--space-1);
}

.deal-next-step-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 8px;
    border-radius: var(--radius-md);
    background: var(--surface-background);
    font-size: var(--font-caption);
}

.deal-next-step-action {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
}

.deal-next-step-item .deal-next-step-date {
    width: auto;
    font-size: var(--font-caption);
    color: var(--text-secondary);
    white-space: nowrap;
}

.deal-next-step-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

.deal-next-step-remove:hover {
    color: var(--status-danger);
    background: rgba(239, 68, 68, 0.1);
}

.deal-account-context {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.deal-context-chip {
    font-size: var(--font-caption);
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-muted, #f0f0f5);
    color: var(--text-secondary);
}

.deal-stale-badge {
    font-size: var(--font-caption);
    padding: 2px 8px;
    border-radius: 4px;
    background: #fff3e0;
    color: #e65100;
    font-weight: var(--font-weight-semibold);
}

.form-group label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.required-asterisk {
    color: var(--status-danger, #dc2626);
    font-size: var(--font-caption);
    margin-left: 1px;
}

.form-group.is-required label {
    font-weight: 700;
}

.form-group.is-required .select-with-icon {
    border-color: var(--status-warning, #d97706);
    box-shadow: 0 0 0 1px var(--status-warning, #d97706);
}

.field-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 2px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-neutral-400, #94a3b8);
    cursor: help;
    vertical-align: middle;
    flex-shrink: 0;
}

.field-help-icon:hover,
.field-help-icon:focus-visible {
    color: var(--color-primary, #2563eb);
    background: rgba(37, 99, 235, 0.08);
    outline: none;
}

.field-help-tooltip {
    max-width: 280px;
    z-index: 1300;
}

.deal-inherit-banner {
    padding: var(--space-2);
    margin-bottom: var(--space-2);
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 4px;
    font-size: var(--font-caption);
}

.commission-eligibility-notice {
    margin: 0 0 var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid rgba(180, 83, 9, 0.22);
    border-radius: 8px;
    background: rgba(255, 251, 235, 0.78);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    color: #7c2d12;
    backdrop-filter: blur(10px);
}

.commission-eligibility-notice.hidden {
    display: none;
}

.commission-eligibility-notice strong {
    display: block;
    margin-bottom: 0.15rem;
    color: #7c2d12;
}

.commission-eligibility-notice span {
    display: block;
    color: #92400e;
    font-size: var(--font-caption);
}

#dealCommissionSection.is-ineligible .commission-split-section,
#dealCommissionSection.is-ineligible .deal-form-grid-1,
#dealCommissionSection.is-ineligible .deal-form-grid-2 {
    opacity: 0.66;
}

#dealCommissionSection.is-ineligible input,
#dealCommissionSection.is-ineligible select,
#dealCommissionSection.is-ineligible button {
    filter: saturate(0.85);
}

.read-only-splits {
    opacity: 0.85;
}

/* Account modal — compact chrome, fixed footer, no tab scrollbar */
#accountsModal .modal-content.account-modal,
.account-modal.modal-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    width: min(960px, 94vw);
    height: min(860px, 92vh);
    max-height: 92vh;
}

.account-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.account-modal-header h2 {
    margin: 0;
    font-size: var(--font-title);
    font-weight: var(--font-weight-bold);
    line-height: 1.25;
    color: var(--text-primary);
}

.account-modal .account-360-summary {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-3);
    gap: var(--space-2) var(--space-3);
}

.account-modal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.account-modal .account-form-tabs {
    flex-shrink: 0;
    overflow: visible;
    flex-wrap: wrap;
    padding: 0 var(--space-3);
    scrollbar-width: none;
}

.account-modal .account-form-tabs::-webkit-scrollbar {
    display: none;
}

.account-modal-form .deal-form-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-3);
}

.account-modal-form .deal-tab-panel {
    padding: 0;
    min-height: 420px;
}

.account-form-footer {
    flex-shrink: 0;
    margin-top: 0;
}

.account-form-footer-row {
    justify-content: flex-end;
}

.account-form-footer .deal-form-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.account-form-footer .deal-form-actions .btn {
    min-height: var(--control-height);
    min-width: 140px;
    margin: 0;
}

.account-form-footer .deal-form-actions .btn-secondary,
.account-form-footer .deal-form-actions .btn-primary {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
}

.phone-input-row {
    display: grid;
    grid-template-columns: minmax(120px, 150px) 1fr;
    gap: 8px;
    align-items: stretch;
}

.phone-input-row .phone-country-select {
    min-width: 0;
}

.form-group.is-invalid .phone-input-row .form-input,
.form-group.is-invalid .phone-input-row .custom-select-trigger {
    border-color: var(--status-danger, #dc2626);
}

.account-list-identity {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.account-list-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-input, #eef2f7);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.account-list-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--surface-elevated, #fff);
}

.account-list-status.is-active {
    background: #22c55e;
}

.account-list-status.is-inactive {
    background: #ef4444;
}

.account-list-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

tr.account-row.is-clickable,
tr.entity-row.is-clickable,
tr.is-clickable {
    cursor: pointer;
}

tr.account-row.is-clickable:hover,
tr.entity-row.is-clickable:hover,
tr.is-clickable:hover {
    background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}

.account-modal-form .input-adorned {
    width: 100%;
}

#accountFormTabs .deal-form-tab.has-complete:not(.has-error)::after {
    content: '✓';
    position: static;
    display: inline-block;
    width: auto;
    height: auto;
    margin-left: 5px;
    border-radius: 0;
    background: transparent;
    color: #16a34a;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    line-height: 1;
    top: auto;
    right: auto;
}

.account-modal-form .form-group.is-invalid input,
.account-modal-form .form-group.is-invalid select,
.account-modal-form .form-group.is-invalid textarea,
.account-modal-form .form-group.is-invalid .rating-select-wrap,
.account-modal-form .form-group.is-invalid .currency-input,
.account-modal-form .form-group.is-invalid .input-adorned,
.account-modal-form .form-group.is-invalid .phone-input-row .form-input,
.account-modal-form .form-group.is-invalid .custom-select .custom-select-trigger {
    border-color: var(--status-danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

.account-modal-form [data-field].is-invalid.deal-tab-panel {
    box-shadow: inset 0 0 0 2px rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-md);
}

/* Entity CRUD modals — contacts, users, goals */
.entity-form-modal {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    width: 94%;
    max-width: 640px;
    max-height: 92vh;
}

.entity-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.entity-form-header h2 {
    margin: 0;
    font-size: var(--font-title);
    font-weight: var(--font-weight-bold);
    line-height: 1.25;
    color: var(--text-primary);
}

.entity-form-header .modal-close {
    flex-shrink: 0;
    margin: 0;
}

.entity-modal-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
}

.entity-modal-form .deal-form-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-3);
}

.entity-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3) var(--space-3);
    align-items: start;
}

.entity-form-grid .form-group.full-width,
.entity-form-grid .form-group-full,
.entity-form-grid .contact-linked-section {
    grid-column: 1 / -1;
}

.entity-form-footer {
    flex-shrink: 0;
    margin-top: 0;
}

.entity-form-footer-row {
    justify-content: flex-end;
}

.entity-form-footer .deal-form-actions .btn {
    min-height: var(--control-height);
    margin: 0;
}

.entity-modal-form .form-group.is-invalid input,
.entity-modal-form .form-group.is-invalid select,
.entity-modal-form .form-group.is-invalid textarea,
.entity-modal-form .form-group.is-invalid .custom-select .custom-select-trigger {
    border-color: var(--status-danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}

@media (max-width: 640px) {
    .entity-form-grid {
        grid-template-columns: 1fr;
    }
}

.goals-monthly-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    padding: var(--space-2);
    margin-top: var(--space-1);
    background: var(--surface-background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    grid-column: 1 / -1;
}

.goals-monthly-grid .goal-form-section-label {
    grid-column: 1 / -1;
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.goals-monthly-grid .form-group {
    gap: 2px;
}

.goals-monthly-grid .form-group label {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

.goals-monthly-grid .form-group input {
    min-height: 36px;
    font-size: var(--font-label);
}

@media (max-width: 640px) {
    .goals-monthly-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.goal-form-audit {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    grid-column: 1 / -1;
    padding: var(--space-2);
    margin-top: var(--space-1);
    background: var(--surface-background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.goal-form-audit .form-group {
    gap: 2px;
}

.goal-form-audit .form-group label {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

.form-input-readonly {
    display: block;
    padding: var(--space-1) 0;
    font-size: var(--font-label);
    color: var(--text-primary);
    min-height: 36px;
    line-height: 1.5;
}

.probability-control {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.probability-slider-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.probability-slider {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 6px;
    margin: 0;
    accent-color: var(--color-primary, #2563eb);
    cursor: pointer;
}

.probability-slider-value {
    min-width: 3.25rem;
    text-align: right;
    font-size: var(--font-label);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    user-select: none;
    pointer-events: none;
}

.probability-control-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.probability-number-wrap {
    flex: 0 0 auto;
    max-width: 8rem;
}

.probability-number-wrap input[type="number"] {
    width: 5.5rem;
}

.probability-value-label {
    font-size: var(--text-sm, 0.875rem);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary, #64748b);
    min-width: 4rem;
    text-align: right;
}

#dealProbabilityRangeHint {
    margin: 0;
    font-size: var(--text-xs, 0.75rem);
    color: var(--color-text-muted, #94a3b8);
}

/* ── Goal Progress Bars ── */
.goal-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}
.goal-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border-subtle);
    border-radius: 4px;
    overflow: hidden;
}
.goal-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.goal-progress-fill.on-track { background: var(--color-success, #22c55e); }
.goal-progress-fill.behind  { background: var(--color-danger, #ef4444); }
.goal-progress-fill.complete { background: var(--color-primary, #2563eb); }
.goal-progress-pct {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 3em;
    text-align: right;
}

/* ── Goal Status Badges ── */
.goal-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}
.goal-status-badge.status-completed { background: rgba(34, 197, 94, 0.12); color: #166534; }
.goal-status-badge.status-paused    { background: rgba(250, 204, 21, 0.12); color: #854d0e; }
.goal-status-badge.status-behind    { background: rgba(239, 68, 68, 0.12); color: #991b1b; }
.goal-status-badge.status-on-track  { background: rgba(59, 130, 246, 0.12); color: #1e40af; }

/* ── Goal Summary Cards ── */
.goal-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.goal-summary-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--surface-background);
    border: 1px solid var(--border-subtle);
}
.goal-summary-card.card-current-month {
    background: #f0f9ff;
    border-color: #93c5fd;
}
.goal-summary-card.card-on-track {
    background: #f0fdf4;
    border-color: #86efac;
}
.goal-summary-card.card-behind {
    background: #fef2f2;
    border-color: #fca5a5;
}
.goal-summary-card.card-completed {
    background: #eff6ff;
    border-color: #93c5fd;
}
.goal-summary-num {
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}
.goal-summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.goal-filter-tag {
    font-size: 0.65rem;
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 2px;
}

/* ── Goal Month Badge ── */
.goal-month-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    background: #e0f2fe;
    color: #0369a1;
}
.goal-month-badge.year-badge {
    background: #f3e8ff;
    color: #6b21a8;
}
.goal-month-badge.quarter-badge {
    background: #fef3c7;
    color: #92400e;
}

/* ── Goal Form Row (Year + Period side by side) ── */
.goal-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    grid-column: 1 / -1;
}

/* ── Goal Period Grid (Monthly 12 cells, Quarterly 4 cells) ── */
.goal-period-grid, .goal-monthly-grid, .goal-quarterly-grid {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    padding: var(--space-2);
    margin-top: var(--space-1);
    background: var(--surface-background);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    grid-column: 1 / -1;
}
.goal-period-grid-label {
    grid-column: 1 / -1;
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0;
}
.goal-period-cell {
    gap: 2px;
}
.goal-period-cell label {
    font-size: var(--font-caption);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}
.goal-period-cell input {
    min-height: 36px;
    font-size: var(--font-label);
}
.goal-period-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--space-2);
    padding-top: var(--space-1);
}

/* ── Field Info Icons with Tooltips ── */
.field-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border-subtle);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    font-style: normal;
    cursor: help;
    position: relative;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
}
.field-info-icon:hover {
    background: var(--color-primary, #2563eb);
    color: #fff;
}
.field-info-icon::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 11px;
    font-weight: normal;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 260px;
    white-space: normal;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.field-info-icon:hover::after {
    opacity: 1;
}

/* ── Goal Filter Dropdowns ── */
.goal-filters {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}
.goal-filter {
    min-width: 120px;
}

/* ── Goal Type Label ── */
.goal-type-label {
    font-weight: var(--font-weight-medium);
}

@media (max-width: 640px) {
    .goal-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .goal-period-grid, .goal-monthly-grid, .goal-quarterly-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .goal-filters {
        flex-wrap: wrap;
        margin-left: 0;
        width: 100%;
    }
    .goal-filter {
        flex: 1;
        min-width: 100px;
    }
}

/* ── Billing Schedule Panels ── */
.billing-schedule-panel {
    padding: var(--space-2) 0;
}

.billing-schedule-panel.hidden {
    display: none;
}

/* ── Billing Table (Milestone / Custom Schedule) ── */
.billing-table-wrapper {
    overflow-x: auto;
    margin-bottom: var(--space-2);
}

.billing-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: var(--font-label);
}

.billing-table th {
    text-align: left;
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
}

.billing-table td {
    padding: var(--space-1) var(--space-2);
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
}

.billing-table td input,
.billing-table td select {
    /* width: 100%; */
    box-sizing: border-box;
    min-height: 36px;
    font-size: var(--font-label);
    padding: 0 var(--space-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    color: var(--text-primary);
}

.billing-table td input:focus,
.billing-table td select:focus {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}

.billing-table .ms-remove,
.billing-table .cs-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
    border-radius: var(--radius-md);
}

.billing-table .ms-remove:hover,
.billing-table .cs-remove:hover {
    color: var(--status-danger);
    background: rgba(239, 68, 68, 0.08);
}

/* ── Milestone Table Column Sizing ── */
#dealMilestonePanel .billing-table-wrapper {
    overflow-x: auto;
}

#dealMilestoneTable {
    width: max-content;
    min-width: 100%;
}

#dealMilestoneTable th.col-index,
#dealMilestoneTable td.col-index,
#dealMilestoneTable th:nth-child(1),
#dealMilestoneTable td:nth-child(1) {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    padding-left: 2px;
    padding-right: 2px;
    text-align: center;
    font-size: var(--font-caption);
}

#dealMilestoneTable th.col-name,
#dealMilestoneTable td.col-name,
#dealMilestoneTable th:nth-child(2),
#dealMilestoneTable td:nth-child(2) {
    width: 32%;
    min-width: 120px;
}

#dealMilestoneTable th.col-date,
#dealMilestoneTable td.col-date,
#dealMilestoneTable th:nth-child(3),
#dealMilestoneTable td:nth-child(3) {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
}

#dealMilestoneTable th.col-amount,
#dealMilestoneTable td.col-amount,
#dealMilestoneTable th:nth-child(4),
#dealMilestoneTable td:nth-child(4) {
    width: 20%;
    min-width: 120px;
}

#dealMilestoneTable th.col-notes,
#dealMilestoneTable td.col-notes,
#dealMilestoneTable th:nth-child(7),
#dealMilestoneTable td:nth-child(7) {
    width: 160px;
    min-width: 160px;
}

#dealMilestoneTable th.col-remove,
#dealMilestoneTable td.col-remove,
#dealMilestoneTable th:nth-child(8),
#dealMilestoneTable td:nth-child(8) {
    width: 24px;
    min-width: 24px;
    max-width: 24px;
    text-align: center;
    padding-left: 2px;
    padding-right: 2px;
}

#dealMilestoneTable.tax-columns-visible th.col-name,
#dealMilestoneTable.tax-columns-visible td.col-name,
#dealMilestoneTable.tax-columns-visible th:nth-child(2),
#dealMilestoneTable.tax-columns-visible td:nth-child(2) {
    width: 20%;
    min-width: 110px;
}

#dealMilestoneTable.tax-columns-visible th.col-date,
#dealMilestoneTable.tax-columns-visible td.col-date,
#dealMilestoneTable.tax-columns-visible th:nth-child(3),
#dealMilestoneTable.tax-columns-visible td:nth-child(3) {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
}

#dealMilestoneTable.tax-columns-visible th.col-amount,
#dealMilestoneTable.tax-columns-visible td.col-amount,
#dealMilestoneTable.tax-columns-visible th:nth-child(4),
#dealMilestoneTable.tax-columns-visible td:nth-child(4) {
    width: 16%;
    min-width: 108px;
}

#dealMilestoneTable.tax-columns-visible th:nth-child(5),
#dealMilestoneTable.tax-columns-visible td:nth-child(5),
#dealMilestoneTable.tax-columns-visible th.col-tax-rate,
#dealMilestoneTable.tax-columns-visible td.col-tax-rate {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    text-align: center;
}

#dealMilestoneTable.tax-columns-visible th:nth-child(6),
#dealMilestoneTable.tax-columns-visible td:nth-child(6),
#dealMilestoneTable.tax-columns-visible th.col-amount-tax,
#dealMilestoneTable.tax-columns-visible td.col-amount-tax {
    width: 76px;
    min-width: 76px;
    max-width: 76px;
    white-space: nowrap;
}

#dealMilestoneTable.tax-columns-visible th.col-notes,
#dealMilestoneTable.tax-columns-visible td.col-notes,
#dealMilestoneTable.tax-columns-visible th:nth-child(7),
#dealMilestoneTable.tax-columns-visible td:nth-child(7) {
    width: 160px;
    min-width: 160px;
}

#dealMilestoneTable td .input-adorned {
    min-height: 36px;
    width: 100%;
}

#dealMilestoneTable .input-adorned .input-prefix {
    padding: 0 4px;
    min-width: 14px;
    font-size: var(--font-caption);
}

#dealMilestoneTable .input-adorned input.ms-amount {
    padding: 0 6px;
    font-variant-numeric: tabular-nums;
}

#dealMilestoneTable .ms-remove {
    padding: 2px 3px;
    font-size: 14px;
    line-height: 1;
    min-width: 0;
}

#dealMilestoneTable .ms-title,
#dealMilestoneTable .ms-notes {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: 40px;
    overflow: hidden;
    resize: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
    padding-top: 8px;
    padding-bottom: 8px;
    field-sizing: content;
}

#dealMilestoneTable td.col-name,
#dealMilestoneTable td.col-notes {
    vertical-align: top;
}

/* ── Milestone Validation ── */
.milestone-validation {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-1) var(--space-2);
    margin-top: var(--space-1);
    font-size: var(--font-label);
}

.milestone-validation .validation-equal {
    color: var(--status-success);
    font-weight: var(--font-weight-semibold);
}

.milestone-validation .validation-mismatch {
    color: var(--status-danger);
    font-weight: var(--font-weight-semibold);
}

/* ── Custom Schedule Totals ── */
/* Date warning banner */
.deal-date-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
}
.deal-date-warning.hidden { display: none; }

/* Payment count unit hint */
#dealPaymentCountUnit {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Billing schedule panel section */
.billing-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}
.billing-section-label {
    font-weight: 600;
    font-size: 13px;
    display: block;
    color: var(--text-primary);
}
.billing-add-btn {
    margin-bottom: var(--space-2);
}
.billing-schedule-panel-section .billing-add-btn,
.billing-empty-state .btn {
    margin-left: 0;
}

/* Billing table alignment */
.billing-table-wrapper {
    overflow-x: auto;
    margin-bottom: var(--space-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}
.billing-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: var(--font-label);
}
.billing-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-background);
    z-index: 2;
    text-align: left;
    padding: var(--space-2);
    font-size: var(--font-caption);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
    border-bottom: 2px solid var(--border-subtle);
    white-space: nowrap;
}
.billing-table tbody td {
    padding: var(--space-2);
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
}
.billing-table tbody tr:hover td {
    background: var(--surface-hover);
}
.billing-table tbody tr:last-child td {
    border-bottom: none;
}
.billing-table td input,
.billing-table td select,
.billing-table td textarea {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    font-size: var(--font-label);
    padding: 0 var(--space-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    color: var(--text-primary);
}
.billing-table td input:focus,
.billing-table td select:focus,
.billing-table td textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}
.billing-table .ms-remove,
.billing-table .cs-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    font-size: 18px;
    line-height: 1;
    border-radius: var(--radius-md);
    transition: color 0.15s ease, background 0.15s ease;
}
.billing-table .ms-remove:hover,
.billing-table .cs-remove:hover {
    color: var(--status-danger);
    background: rgba(239, 68, 68, 0.08);
}
.billing-table .ms-duplicate,
.billing-table .cs-duplicate {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    font-size: 16px;
    line-height: 1;
    border-radius: var(--radius-md);
    transition: color 0.15s ease, background 0.15s ease;
}
.billing-table .ms-duplicate:hover,
.billing-table .cs-duplicate:hover {
    color: var(--brand-primary);
    background: rgba(37, 99, 235, 0.08);
}

/* Milestone table column sizing */
#dealMilestoneTable {
    table-layout: fixed;
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}
#dealMilestoneTable th,
#dealMilestoneTable td {
    padding: 8px 6px;
    vertical-align: middle;
}
#dealMilestoneTable th.col-index,
#dealMilestoneTable td.col-index,
#dealMilestoneTable th:nth-child(1),
#dealMilestoneTable td:nth-child(1) { width: 24px; min-width: 24px; max-width: 24px; padding-left: 2px; padding-right: 2px; text-align: center; font-size: var(--font-caption); }
#dealMilestoneTable th.col-name,
#dealMilestoneTable td.col-name,
#dealMilestoneTable th:nth-child(2),
#dealMilestoneTable td:nth-child(2) { width: 32%; min-width: 120px; }
#dealMilestoneTable th.col-date,
#dealMilestoneTable td.col-date,
#dealMilestoneTable th:nth-child(3),
#dealMilestoneTable td:nth-child(3) { width: 96px; min-width: 96px; max-width: 96px; }
#dealMilestoneTable th.col-amount,
#dealMilestoneTable td.col-amount,
#dealMilestoneTable th:nth-child(4),
#dealMilestoneTable td:nth-child(4) { width: 20%; min-width: 120px; }
#dealMilestoneTable th.col-notes,
#dealMilestoneTable td.col-notes,
#dealMilestoneTable th:nth-child(7),
#dealMilestoneTable td:nth-child(7) { width: 160px; min-width: 160px; }
#dealMilestoneTable th.col-remove,
#dealMilestoneTable td.col-remove,
#dealMilestoneTable th:nth-child(8),
#dealMilestoneTable td:nth-child(8) { width: 24px; min-width: 24px; max-width: 24px; text-align: center; padding-left: 2px; padding-right: 2px; }
#dealMilestoneTable.tax-columns-visible th.col-index,
#dealMilestoneTable.tax-columns-visible td.col-index,
#dealMilestoneTable.tax-columns-visible th:nth-child(1),
#dealMilestoneTable.tax-columns-visible td:nth-child(1) { width: 24px; min-width: 24px; max-width: 24px; }
#dealMilestoneTable.tax-columns-visible th.col-name,
#dealMilestoneTable.tax-columns-visible td.col-name,
#dealMilestoneTable.tax-columns-visible th:nth-child(2),
#dealMilestoneTable.tax-columns-visible td:nth-child(2) { width: 20%; min-width: 110px; }
#dealMilestoneTable.tax-columns-visible th.col-date,
#dealMilestoneTable.tax-columns-visible td.col-date,
#dealMilestoneTable.tax-columns-visible th:nth-child(3),
#dealMilestoneTable.tax-columns-visible td:nth-child(3) { width: 96px; min-width: 96px; max-width: 96px; }
#dealMilestoneTable.tax-columns-visible th.col-amount,
#dealMilestoneTable.tax-columns-visible td.col-amount,
#dealMilestoneTable.tax-columns-visible th:nth-child(4),
#dealMilestoneTable.tax-columns-visible td:nth-child(4) { width: 16%; min-width: 108px; }
#dealMilestoneTable.tax-columns-visible th:nth-child(5),
#dealMilestoneTable.tax-columns-visible td:nth-child(5),
#dealMilestoneTable.tax-columns-visible th.col-tax-rate,
#dealMilestoneTable.tax-columns-visible td.col-tax-rate { width: 48px; min-width: 48px; max-width: 48px; text-align: center; }
#dealMilestoneTable.tax-columns-visible th:nth-child(6),
#dealMilestoneTable.tax-columns-visible td:nth-child(6),
#dealMilestoneTable.tax-columns-visible th.col-amount-tax,
#dealMilestoneTable.tax-columns-visible td.col-amount-tax { width: 76px; min-width: 76px; max-width: 76px; white-space: nowrap; }
#dealMilestoneTable.tax-columns-visible th.col-notes,
#dealMilestoneTable.tax-columns-visible td.col-notes,
#dealMilestoneTable.tax-columns-visible th:nth-child(7),
#dealMilestoneTable.tax-columns-visible td:nth-child(7) { width: 160px; min-width: 160px; }
#dealMilestoneTable td.col-amount input,
#dealMilestoneTable td:nth-child(4) input { text-align: right; }
#dealMilestoneTable td .input-adorned { min-height: 40px; width: 100%; }
#dealMilestoneTable .input-adorned .input-prefix {
    padding: 0 4px;
    min-width: 14px;
    font-size: var(--font-caption);
}
#dealMilestoneTable .input-adorned input.ms-amount {
    padding: 0 6px;
    font-variant-numeric: tabular-nums;
}
#dealMilestoneTable .ms-remove {
    padding: 2px 3px;
    font-size: 14px;
    line-height: 1;
    min-width: 0;
}
#dealMilestoneTable .ms-title,
#dealMilestoneTable .ms-notes {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    height: 40px;
    overflow: hidden;
    resize: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
    padding-top: 8px;
    padding-bottom: 8px;
    field-sizing: content;
}
#dealMilestoneTable td.col-name,
#dealMilestoneTable td.col-notes,
#dealMilestoneTable td:nth-child(2) {
    vertical-align: top;
}
#dealMilestoneTable .custom-date-field,
#dealMilestoneTable .input-adorned {
    max-width: 100%;
    width: 100%;
}
#dealMilestoneTable td.col-date,
#dealMilestoneTable td:nth-child(3) {
    white-space: nowrap;
}
#dealMilestoneTable .ms-date-display {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    min-width: 0;
    width: 100%;
    padding-left: 6px;
    padding-right: 28px;
    font-size: var(--font-caption);
}

#dealMilestoneTable td.col-amount-tax,
#dealMilestoneTable td.col-amount-tax,
#dealMilestoneTable td.ms-amount-with-tax {
    font-size: var(--font-caption);
    padding-left: 4px;
    padding-right: 4px;
}

/* Custom schedule: #, date, amount, tax, with tax, notes, remove */
#dealCustomScheduleTable {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}
#dealCustomScheduleTable th,
#dealCustomScheduleTable td {
    padding: 8px 8px;
    vertical-align: middle;
}
#dealCustomScheduleTable th:nth-child(1),
#dealCustomScheduleTable td:nth-child(1) {
    width: 4%;
    text-align: center;
}
#dealCustomScheduleTable th:nth-child(2),
#dealCustomScheduleTable td:nth-child(2) {
    width: 22%;
}
#dealCustomScheduleTable th:nth-child(3),
#dealCustomScheduleTable td:nth-child(3) {
    width: 34%;
}
#dealCustomScheduleTable th:nth-child(6),
#dealCustomScheduleTable td:nth-child(6) {
    width: 32%;
}
#dealCustomScheduleTable th:nth-child(7),
#dealCustomScheduleTable td:nth-child(7) {
    width: 8%;
    text-align: center;
}
#dealCustomScheduleTable.tax-columns-visible th:nth-child(2),
#dealCustomScheduleTable.tax-columns-visible td:nth-child(2) {
    width: 18%;
}
#dealCustomScheduleTable.tax-columns-visible th:nth-child(3),
#dealCustomScheduleTable.tax-columns-visible td:nth-child(3) {
    width: 24%;
}
#dealCustomScheduleTable.tax-columns-visible th:nth-child(4),
#dealCustomScheduleTable.tax-columns-visible td:nth-child(4) {
    width: 10%;
}
#dealCustomScheduleTable.tax-columns-visible th:nth-child(5),
#dealCustomScheduleTable.tax-columns-visible td:nth-child(5) {
    width: 16%;
}
#dealCustomScheduleTable.tax-columns-visible th:nth-child(6),
#dealCustomScheduleTable.tax-columns-visible td:nth-child(6) {
    width: 20%;
}
#dealCustomScheduleTable td:nth-child(2) .custom-date-field,
#dealCustomScheduleTable td:nth-child(2) .form-input,
#dealCustomScheduleTable td:nth-child(3) .input-adorned,
#dealCustomScheduleTable td:nth-child(3) input,
#dealCustomScheduleTable td:nth-child(6) .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
#dealCustomScheduleTable td:nth-child(3) input { text-align: right; }
#dealCustomScheduleTable td .input-adorned { min-height: 40px; }

/* Validation styles */
.milestone-validation {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-1) var(--space-2);
    margin-top: var(--space-1);
    font-size: var(--font-label);
}
.milestone-validation .validation-equal { color: var(--status-success); font-weight: var(--font-weight-semibold); }
.milestone-validation .validation-mismatch { color: var(--status-danger); font-weight: var(--font-weight-semibold); }

/* Billing schedule totals */
.billing-schedule-totals {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-2) var(--space-2);
    margin-top: var(--space-1);
    font-size: var(--font-label);
    background: var(--surface-background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}
.billing-schedule-totals .status-complete { color: var(--status-success); font-weight: var(--font-weight-semibold); }
.billing-schedule-totals .status-mismatch { color: var(--status-danger); font-weight: var(--font-weight-semibold); }
.billing-schedule-totals .status-warning { color: var(--status-warning); font-weight: var(--font-weight-semibold); }

/* Empty state */
.billing-empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-2);
    margin-top: var(--space-2);
    background: var(--surface-background);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-default);
    color: var(--text-secondary);
    font-size: var(--font-label);
}
.billing-empty-state .btn { margin-left: 0; }
.billing-empty-state.hidden { display: none !important; }

/* Shared tax controls (all payment models) */
.billing-tax-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.billing-tax-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 32px;
}
.billing-tax-toolbar .toggle-label-group {
    margin-left: 0;
}
.billing-tax-calc {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.billing-tax-calc.hidden {
    display: none !important;
}
.billing-tax-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
.billing-tax-fields .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    margin: 0;
}
.billing-tax-fields .form-group > label {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.billing-tax-fields .form-input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
}
.billing-tax-value {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-background);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}
.billing-tax-total {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}
.billing-tax-total > label {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.billing-tax-total > strong {
    font-size: 18px;
    color: var(--brand-primary);
}
@media (max-width: 768px) {
    .billing-tax-fields {
        grid-template-columns: 1fr;
    }
}

/* Billing section header with inline toggle */
.billing-section-header .toggle-label-group {
    margin-left: 0;
    flex-shrink: 0;
}

/* Recurring schedule column sizing: # 10% · Date 40% · Amount 50% (tax off) */
#dealRecurringScheduleTable {
    table-layout: fixed;
    width: 100%;
}
#dealRecurringScheduleTable th.col-sno,
#dealRecurringScheduleTable td.col-sno {
    width: 10%;
    text-align: center;
    padding-left: var(--space-1);
    padding-right: var(--space-1);
}
#dealRecurringScheduleTable th.col-date,
#dealRecurringScheduleTable td.col-date {
    width: 40%;
}
#dealRecurringScheduleTable th.col-amount,
#dealRecurringScheduleTable td.col-amount {
    width: 50%;
}
#dealRecurringScheduleTable.tax-columns-visible th.col-sno,
#dealRecurringScheduleTable.tax-columns-visible td.col-sno {
    width: 8%;
}
#dealRecurringScheduleTable.tax-columns-visible th.col-date,
#dealRecurringScheduleTable.tax-columns-visible td.col-date {
    width: 28%;
}
#dealRecurringScheduleTable.tax-columns-visible th.col-amount,
#dealRecurringScheduleTable.tax-columns-visible td.col-amount {
    width: 24%;
}
.billing-table th.col-tax-rate,
.billing-table td.col-tax-rate {
    width: 10%;
    text-align: center;
    white-space: nowrap;
    color: var(--text-secondary);
}
.billing-table th.col-amount-tax,
.billing-table td.col-amount-tax {
    width: 16%;
    white-space: nowrap;
    font-weight: var(--font-weight-medium);
}
#dealRecurringScheduleTable .col-date .custom-date-field,
#dealRecurringScheduleTable .col-date .form-input,
#dealRecurringScheduleTable .col-amount .input-adorned,
#dealRecurringScheduleTable .col-amount .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ongoing support schedule: narrow index, even remaining columns */
#dealOngoingScheduleTable {
    table-layout: fixed;
    width: 100%;
}
#dealOngoingScheduleTable th.col-sno,
#dealOngoingScheduleTable td.col-sno {
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    text-align: center;
    padding-left: 4px;
    padding-right: 4px;
    font-size: var(--font-caption);
}
#dealOngoingScheduleTable:not(.tax-columns-visible) th.col-date,
#dealOngoingScheduleTable:not(.tax-columns-visible) td.col-date {
    width: 42%;
}
#dealOngoingScheduleTable:not(.tax-columns-visible) th.col-amount,
#dealOngoingScheduleTable:not(.tax-columns-visible) td.col-amount {
    width: 58%;
}
#dealOngoingScheduleTable.tax-columns-visible th.col-date,
#dealOngoingScheduleTable.tax-columns-visible td.col-date {
    width: 28%;
}
#dealOngoingScheduleTable.tax-columns-visible th.col-amount,
#dealOngoingScheduleTable.tax-columns-visible td.col-amount {
    width: 30%;
}
#dealOngoingScheduleTable.tax-columns-visible th.col-tax-rate,
#dealOngoingScheduleTable.tax-columns-visible td.col-tax-rate {
    width: 14%;
}
#dealOngoingScheduleTable.tax-columns-visible th.col-amount-tax,
#dealOngoingScheduleTable.tax-columns-visible td.col-amount-tax {
    width: 18%;
}
#dealOngoingScheduleTable .col-date .custom-date-field,
#dealOngoingScheduleTable .col-date .form-input,
#dealOngoingScheduleTable .col-amount .input-adorned,
#dealOngoingScheduleTable .col-amount .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.billing-table:not(.tax-columns-visible) th.col-tax-rate,
.billing-table:not(.tax-columns-visible) td.col-tax-rate,
.billing-table:not(.tax-columns-visible) th.col-amount-tax,
.billing-table:not(.tax-columns-visible) td.col-amount-tax {
    display: none;
}

.billing-schedule-tax-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md, 8px);
    background: var(--surface-muted, rgba(15, 23, 42, 0.03));
    font-size: var(--font-caption);
    color: var(--text-secondary);
}

.billing-schedule-tax-summary strong {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
}

#sectionRevenueCard .billing-schedule-toggles {
    gap: 20px;
    flex-wrap: wrap;
}
#sectionRevenueCard .billing-schedule-toggles .toggle-label-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ── Billing Summary Grid ── */
.billing-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
}

.billing-summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2);
    background: var(--surface-background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.billing-summary-item-full {
    grid-column: 1 / -1;
}

.billing-summary-label {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.billing-summary-value {
    font-size: var(--font-label);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

/* ── Enterprise Summary Card ── */
.billing-summary-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: sticky;
    top: 0;
}

.billing-summary-card-title {
    margin: 0;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-label);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    background: var(--surface-background);
    border-bottom: 1px solid var(--border-subtle);
}

.billing-summary-card-body {
    padding: var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.billing-summary-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-caption);
    padding: var(--space-1) 0;
}

.billing-summary-card-row + .billing-summary-card-row {
    border-top: 1px solid var(--border-subtle);
}

.billing-summary-card-row span:first-child {
    color: var(--text-secondary);
}

.billing-summary-card-value {
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.billing-summary-card-status .billing-summary-card-value {
    color: var(--status-warning);
}

.billing-summary-card-status .billing-summary-card-value.status-ready {
    color: var(--status-success);
}

/* ── Form group checkbox tweaks ── */

.invoice-frequency-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

@media (max-width: 640px) {
    .billing-summary-grid {
        grid-template-columns: 1fr;
    }
    .billing-layout {
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════════════════════
   PIPELINE OVERVIEW STAGE HEADERS
   ════════════════════════════════════════════════════════════════ */

.pipeline-overview {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    background: #fafafa;
}

.pipeline-overview-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.pipeline-stages-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.pipeline-stage-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s;
    cursor: pointer;
}

.pipeline-stage-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.pipeline-stage-card.is-active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.pipeline-stage-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.pipeline-stage-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.pipeline-stage-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
}

.pipeline-stage-settings {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pipeline-stage-settings:hover {
    background: #f3f4f6;
    color: #374151;
}

.pipeline-stage-range {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
    font-weight: 500;
}

.pipeline-stage-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

.pipeline-stage-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pipeline-stage-metric-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.pipeline-stage-metric-value {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.pipeline-stage-metric-value.is-forecast {
    color: #2563eb;
}

/* Stage color variants */
.pipeline-stage-card[data-stage-color="orange"] .pipeline-stage-number {
    background: #f97316;
}

.pipeline-stage-card[data-stage-color="blue"] .pipeline-stage-number {
    background: #2563eb;
}

.pipeline-stage-card[data-stage-color="purple"] .pipeline-stage-number {
    background: #a855f7;
}

.pipeline-stage-card[data-stage-color="green"] .pipeline-stage-number {
    background: #10b981;
}

.pipeline-stage-card[data-stage-color="gray"] .pipeline-stage-number {
    background: #6b7280;
}

/* ════════════════════════════════════════════════════════════════
   PREMIUM CRM UI ENHANCEMENTS — Salesforce/HubSpot-inspired design
   Added: 2-column layout, stepper, sidebar cards, badges, etc.
   ════════════════════════════════════════════════════════════════ */

/* ── Premium Variables ── */
.premium-enabled .modal-content.modal-deal {
    width: min(96vw, 1600px);
    max-width: 1600px;
}

/* ── Compact Status Badges Row ── */
.deal-form-status-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 var(--space-3) var(--space-1);
    margin-top: -2px;
}

.deal-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border-subtle);
    background: var(--surface-background);
    color: var(--text-secondary);
}

.deal-status-badge.is-info {
    background: var(--brand-primary-subtle, #dbeafe);
    color: var(--brand-primary, #2563eb);
    border-color: #bfdbfe;
}

.deal-status-badge.is-success {
    background: #d1fae5;
    color: #059669;
    border-color: #a7f3d0;
}

.deal-status-badge.is-warning {
    background: #fef3c7;
    color: #d97706;
    border-color: #fde68a;
}

/* ── Stepper Navigation ── */
.deal-form-stepper {
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
    margin: var(--space-2) 0;
    gap: 0;
}

.deal-stepper-step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    cursor: pointer;
    user-select: none;
}

.deal-stepper-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--brand-primary, #2563eb);
    color: white;
    flex-shrink: 0;
    transition: all 0.2s;
}

.deal-stepper-circle.is-inactive {
    background: var(--surface-muted, #e5e7eb);
    color: var(--text-muted, #9ca3af);
}

.deal-stepper-circle.is-complete {
    background: var(--status-success, #10b981);
}

.deal-stepper-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.deal-stepper-label.is-inactive {
    color: var(--text-secondary);
}

.deal-stepper-connector {
    flex: 1;
    height: 2px;
    background: var(--border-default, #e5e7eb);
    margin: 0 12px;
    min-width: 30px;
}

.deal-stepper-connector.is-active {
    background: var(--brand-primary, #2563eb);
}

/* ── Two-Column Layout ── */
.deal-form-body.is-premium-layout {
    display: grid;
    /* Sidebar must shrink under zoom; fixed 600px was clipping the commission step. */
    grid-template-columns: minmax(0, 1fr) minmax(280px, 400px);
    gap: 24px;
    padding: var(--space-2) var(--space-3) var(--space-3);
    min-height: 0;
    overflow: hidden;
}

.deal-form-body.is-premium-layout .deal-tab-panel {
    padding: 0;
}

.deal-form-left-column {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    overflow-x: auto;
    padding-right: 4px;
}

.deal-form-body.is-premium-layout [data-stepper-panel].premium-card,
.deal-form-body.is-premium-layout #sectionDetailsCard,
.deal-form-body.is-premium-layout #sectionRevenueCard,
.deal-form-body.is-premium-layout #sectionContactsCard,
.deal-form-body.is-premium-layout #sectionCommissionCard {
    scroll-margin-top: 12px;
}

.deal-form-right-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
}

/* Commission card: adapt when the left column is squeezed (zoom / narrow windows). */
#sectionCommissionCard {
    container-type: inline-size;
    container-name: commission-card;
    max-width: 100%;
    min-width: 0;
}

#sectionCommissionCard #dealCommissionSection,
#sectionCommissionCard #dealCommissionConfigArea {
    min-width: 0;
    max-width: 100%;
}

#sectionCommissionCard .commission-recipients-table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Soft adaptations only — keep Role / Relation / Share visible at normal 100% zoom. */
@container commission-card (max-width: 780px) {
    #sectionCommissionCard .commission-estimate-card {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    #sectionCommissionCard .commission-estimate-meta {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 12px 16px;
    }
}

/* Compact stacked recipients only when the card is truly narrow. */
@container commission-card (max-width: 520px) {
    #sectionCommissionCard .deal-form-grid-2 {
        grid-template-columns: 1fr;
    }

    #sectionCommissionCard .commission-eligibility-check {
        padding-left: 0;
    }

    #sectionCommissionCard .commission-recipients-header {
        flex-direction: column;
        align-items: stretch;
    }

    #sectionCommissionCard .recipients-header-actions {
        flex-wrap: wrap;
    }

    #sectionCommissionCard .commission-recipients-columns-header {
        display: none;
    }

    #sectionCommissionCard .commission-recipient-card {
        grid-template-columns: 40px minmax(0, 1fr) 36px;
        min-width: 0;
        gap: 10px;
        padding: 12px 14px;
    }

    #sectionCommissionCard .recipient-role-cell {
        display: none;
    }

    #sectionCommissionCard .recipient-relation-cell {
        grid-column: 2;
        grid-row: 2;
        display: flex;
    }

    #sectionCommissionCard .recipient-share {
        grid-column: 2;
        grid-row: 3;
        max-width: 120px;
    }

    #sectionCommissionCard .recipient-receives-area {
        grid-column: 2;
        grid-row: 4;
    }

    #sectionCommissionCard .recipient-share-wrap {
        max-width: 120px;
    }

    #sectionCommissionCard .recipient-share-wrap .split-pct {
        width: 88px;
        max-width: 88px;
    }
}

/* ── Premium Cards ── */
.premium-card {
    background: white;
    border: 1px solid var(--border-default, #e5e7eb);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow: visible;
}

.premium-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.premium-card-header-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.premium-card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    display: flex;
    align-items: center;
    gap: 10px;
}

.premium-card-number {
    width: 28px;
    height: 28px;
    background: var(--brand-primary, #2563eb);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.premium-card-subtitle {
    font-size: 13px;
    color: var(--text-tertiary, #9ca3af);
    line-height: 1.5;
    margin: 0;
}

/* ── Enhanced Form Inputs ── */
.deal-form .premium-input,
.deal-form .premium-select {
    padding: 10px 14px;
    border: 1px solid var(--border-default, #d1d5db);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary, #1f2937);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    width: 100%;
}

.deal-form .premium-input:focus,
.deal-form .premium-select:focus {
    outline: none;
    border-color: var(--brand-primary, #2563eb);
    box-shadow: 0 0 0 3px var(--brand-primary-subtle, #dbeafe);
}

.premium-input-group {
    display: flex;
    gap: 8px;
}

.premium-input-group .form-input {
    flex: 1;
}

.premium-input-suffix {
    padding: 10px 14px;
    background: var(--surface-background, #f9fafb);
    border: 1px solid var(--border-default, #d1d5db);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* ── Gradient Revenue/Commission Cards ── */
.premium-gradient-card {
    border-radius: 12px;
    padding: 24px;
    color: white;
    margin-top: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.premium-gradient-card.is-revenue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.premium-gradient-card.is-commission {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.premium-gradient-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
}

.premium-gradient-amount {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.premium-gradient-note {
    font-size: 12px;
    opacity: 0.8;
}

/* ── Probability & Forecast Box ── */
.premium-forecast-box {
    margin-top: 20px;
    padding: 16px;
    background: var(--surface-background, #f9fafb);
    border-radius: 8px;
    border: 1px solid var(--border-subtle, #e5e7eb);
}

.premium-forecast-box h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #374151);
    margin-bottom: 12px;
}

/* ── Account Context Chips ── */
.premium-context-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.premium-context-chip {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--surface-muted, #f3f4f6);
    border: 1px solid var(--border-subtle, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}

/* ── Next Step Bar (enhanced) ── */
.deal-next-step-bar.is-premium {
    padding: 12px var(--space-3);
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.deal-next-step-bar.is-premium label {
    white-space: nowrap;
}

.deal-next-step-bar.is-premium .form-input {
    flex: 1;
    min-width: 120px;
}

.deal-next-step-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.deal-next-step-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--brand-primary-subtle, #dbeafe);
    color: var(--brand-primary, #2563eb);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Sidebar Cards ── */
.sidebar-card {
    background: white;
    border: 1px solid var(--border-default, #e5e7eb);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.sidebar-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.sidebar-card-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #6b7280);
    transition: background 0.2s;
}

.sidebar-card-toggle:hover {
    background: var(--surface-muted, #f3f4f6);
}

.sidebar-card-toggle svg {
    transition: transform 0.2s ease;
}

.sidebar-card.collapsed .sidebar-card-toggle svg {
    transform: rotate(-90deg);
}

.sidebar-card.collapsed > *:not(.sidebar-card-title) {
    display: none;
}

/* ── Sidebar Tabs ── */
.sidebar-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-muted, #f3f4f6);
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.sidebar-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.sidebar-tab.is-active {
    background: white;
    color: var(--text-primary, #111827);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* ── Activity Items ── */
.sidebar-activity-item {
    padding: 12px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
}

.sidebar-activity-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary, #1f2937);
    margin-bottom: 6px;
}

.sidebar-activity-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

.sidebar-activity-assignee {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}

/* ── Revenue Summary Card ── */
.sidebar-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    font-size: 14px;
}

.sidebar-summary-row[hidden],
.sidebar-summary-row.hidden {
    display: none !important;
}

.sidebar-summary-row:last-child {
    border-bottom: none;
}

.sidebar-summary-label {
    color: var(--text-secondary, #6b7280);
}

.sidebar-summary-value {
    font-weight: 500;
    color: var(--text-primary, #1f2937);
}

.sidebar-summary-value.is-highlight {
    color: var(--brand-primary, #2563eb);
    font-weight: 600;
}

.sidebar-summary-value.sidebar-diff-under {
    color: var(--status-warning, #d97706);
    font-weight: 600;
}

.sidebar-summary-value.sidebar-diff-over {
    color: var(--status-danger, #dc2626);
    font-weight: 600;
}

.sidebar-invoices-block {
    padding: 10px 0 4px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.sidebar-invoices-heading {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    padding: 4px 0 8px;
    margin-bottom: 0;
}

.sidebar-invoices-cols {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #9ca3af);
    padding: 0 2px 6px;
}

.sidebar-invoices-list {
    max-height: 196px;
    overflow-y: auto;
}

.sidebar-invoice-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    font-size: 13px;
}

.sidebar-invoice-row:last-child {
    border-bottom: none;
}

.sidebar-invoice-date {
    color: var(--text-primary, #1f2937);
}

.sidebar-invoice-amount {
    color: var(--brand-primary, #2563eb);
    font-weight: 600;
}

.sidebar-invoices-empty {
    padding: 8px 2px 4px;
    font-size: 13px;
    color: var(--text-muted, #9ca3af);
}

.sidebar-total-box {
    margin: 10px 0 4px;
    padding: 12px 14px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--brand-primary, #2563eb) 10%, #ffffff);
    border: 1px solid color-mix(in srgb, var(--brand-primary, #2563eb) 18%, #e5e7eb);
}

.sidebar-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.sidebar-total-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-primary, #1d4ed8);
}

.sidebar-total-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-primary, #1d4ed8);
    font-variant-numeric: tabular-nums;
}

.sidebar-total-tax-hint {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary, #6b7280);
}

.sidebar-total-tax-hint[hidden] {
    display: none;
}

.sidebar-total-tax-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--text-muted, #9ca3af);
    font-size: 9px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    color: var(--text-secondary, #6b7280);
    cursor: help;
}

.sidebar-card-expand {
    margin-left: 4px;
    /* margin-right: 8px; */
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
}

.sidebar-card-expand:hover {
    background: var(--surface-hover, #f3f4f6);
    color: var(--text-primary, #1f2937);
}

.timeline-filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.timeline-filter-pill {
    border: 1px solid var(--border-subtle, #e5e7eb);
    background: transparent;
    color: var(--text-secondary, #6b7280);
    border-radius: 999px;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
}

.timeline-filter-pill.is-active {
    background: var(--surface-elevated, #ffffff);
    color: var(--text-primary, #1f2937);
    border-color: var(--text-muted, #9ca3af);
}
.timeline-filter-pill[data-drawer-sort].is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ── Timeline ── */
.sidebar-timeline {
    position: relative;
    padding-left: 24px;
}

.sidebar-timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border-subtle, #e5e7eb);
}

.sidebar-timeline-item {
    position: relative;
    padding-bottom: 16px;
}

.sidebar-card.is-expanded .sidebar-timeline {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.sidebar-timeline-item.is-system {
    padding-left: 2px;
}

.sidebar-timeline-item.is-system .sidebar-timeline-header {
    margin-bottom: 2px;
}

.sidebar-timeline-item.is-system .sidebar-timeline-comment {
    padding: 0;
    background: transparent;
    border-radius: 0;
    margin: 0;
}

.sidebar-system-icon {
    font-size: 13px;
    opacity: 0.85;
}

.sidebar-timeline-meta {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 2px;
}

.sidebar-timeline-item.is-comment {
    padding-left: 32px;
}

.sidebar-timeline-avatar {
    position: absolute;
    left: -20px;
    top: 2px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #0b3a74;
    color: #dbeafe;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-timeline-item:last-child {
    padding-bottom: 0;
}

/* ── Compact timeline row (2-line format) ── */
.sidebar-timeline-item.is-compact {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.sidebar-timeline-item.is-compact:last-child {
    border-bottom: none;
}

.sidebar-timeline-item.is-compact .crm-activity-actions {
    margin-top: 2px;
    padding-left: 0;
}

.sidebar-timeline-item.is-compact .crm-activity-line2 {
    padding-left: 18px;
}

/* Hide old timeline chrome when using compact rows */
.sidebar-timeline-item.is-compact .sidebar-timeline-dot,
.sidebar-timeline-item.is-compact .sidebar-timeline-avatar,
.sidebar-timeline-item.is-compact .sidebar-timeline-header,
.sidebar-timeline-item.is-compact .sidebar-timeline-meta,
.sidebar-timeline-item.is-compact .sidebar-timeline-comment {
    display: none;
}

.sidebar-timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-primary, #2563eb);
    border: 2px solid white;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.sidebar-timeline-dot.is-system {
    background: var(--text-muted, #9ca3af);
}

.sidebar-timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.sidebar-timeline-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

.sidebar-timeline-time {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

.sidebar-timeline-comment {
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.5;
    padding: 8px 12px;
    background: var(--surface-background, #f9fafb);
    border-radius: 8px;
    margin-top: 6px;
}

/* ── Comment Input ── */
.sidebar-comment-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.sidebar-comment-input .form-input {
    flex: 1;
    min-height: 40px;
}

.sidebar-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: var(--brand-primary, #2563eb);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-send-btn:hover {
    background: var(--brand-primary-hover, #1d4ed8);
}

.sidebar-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-comment-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    text-align: right;


.sidebar-mention-menu {
    margin-top: 6px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    background: var(--surface-elevated, #ffffff);
    max-height: 180px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.sidebar-mention-option {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-primary, #1f2937);
    cursor: pointer;
}

.sidebar-mention-option:hover {
    background: var(--surface-hover, #f3f4f6);
}

.sidebar-mention-secondary {
    color: var(--text-muted, #9ca3af);
    margin-left: 6px;
    font-size: 11px;
}
/* ── Timeline Actions ── */
.sidebar-timeline-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding-left: 4px;
}

.sidebar-timeline-actions .link-btn {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.sidebar-timeline-actions .link-btn:hover {
    color: var(--brand-primary, #2563eb);
    background: var(--surface-hover, #f3f4f6);
}

/* ── Internal Badge ── */
.internal-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fef3c7;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: 6px;
}

.crm-activity-header .internal-badge {
    vertical-align: middle;
}

/* ── Edited Label ── */
.edited-label {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    font-style: italic;
    margin-left: 4px;
}

/* ── Deleted Comment ── */
.deleted-comment {
    color: var(--text-muted, #9ca3af);
    font-style: italic;
    font-size: 12px;
}

.sidebar-timeline-item.is-deleted .sidebar-timeline-dot {
    background: var(--text-muted, #d1d5db);
}

.crm-activity-item.is-deleted {
    opacity: 0.6;
    background: var(--surface-background, #f9fafb);
}

/* ── Inline Edit ── */
.inline-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inline-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
}

.inline-edit-textarea:focus {
    outline: none;
    border-color: var(--brand-primary, #2563eb);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.inline-edit-actions {
    display: flex;
    gap: 8px;
}

.inline-edit-actions .btn-xs {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 6px;
}

/* ── Sidebar Internal Checkbox ── */
.sidebar-comment-internal {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    margin-top: 6px;
    cursor: pointer;
    user-select: none;
}

.sidebar-comment-internal input[type="checkbox"] {
    margin: 0;
}

/* ── Comment Modal Internal Checkbox ── */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
}
}

/* ── Enhanced Add Button (dashed) ── */
.premium-add-btn {
    width: 100%;
    padding: 10px;
    border: 1px dashed var(--border-default, #d1d5db);
    background: transparent;
    color: var(--text-muted, #9ca3af);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    font-family: inherit;
    margin-top: 8px;
}

.premium-add-btn:hover {
    border-color: var(--brand-primary, #2563eb);
    color: var(--brand-primary, #2563eb);
    background: var(--brand-primary-subtle, #dbeafe);
}

.premium-add-btn.is-sm {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ── Toggle Switch ── */
.premium-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--surface-muted, #d1d5db);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
    display: inline-block;
}

.premium-toggle.is-active {
    background: var(--brand-primary, #2563eb);
}

.premium-toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.premium-toggle.is-active::after {
    transform: translateX(20px);
}

/* ── Premium Checkbox ── */
.premium-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-default, #d1d5db);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    display: inline-block;
}

.premium-checkbox.is-checked {
    background: var(--brand-primary, #2563eb);
    border-color: var(--brand-primary, #2563eb);
}

.premium-checkbox.is-checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.premium-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary, #374151);
}

/* ── Enhanced Commission Header ── */
.premium-commission-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.premium-commission-field {
    flex: 1;
    min-width: 120px;
}

.premium-commission-field .form-label {
    display: block;
    margin-bottom: 6px;
}

/* ── Contact Table (enhanced) ── */
.premium-contact-table {
    margin-top: 16px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
}

.premium-contact-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface-background, #f9fafb);
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.premium-contact-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1.5fr 1.5fr 80px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    font-size: 14px;
    transition: background 0.15s;
}

.premium-contact-row:last-child {
    border-bottom: none;
}

.premium-contact-row:hover {
    background: var(--surface-background, #f9fafb);
}

.premium-contact-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.premium-contact-avatar.is-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.premium-contact-name {
    font-weight: 500;
    color: var(--text-primary, #1f2937);
}

.premium-primary-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    background: var(--brand-primary-subtle, #dbeafe);
    color: var(--brand-primary, #2563eb);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

/* ── Enhanced Collapsible ── */
.premium-collapsible {
    margin-top: 16px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
}

.premium-collapsible-header {
    padding: 14px 16px;
    background: var(--surface-background, #f9fafb);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    transition: background 0.2s;
    user-select: none;
}

.premium-collapsible-header:hover {
    background: var(--surface-muted, #f3f4f6);
}

.premium-collapsible-body {
    padding: 16px;
    display: none;
}

.premium-collapsible-body.is-open {
    display: block;
}

/* ── Date Warning ── */
.premium-date-warning {
    padding: 8px 12px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 12px;
    border: 1px solid #fde68a;
}

/* ── Reply Action Button ── */
.sidebar-reply-btn {
    margin-top: 6px;
    padding: 4px 8px;
    font-size: 11px;
    width: auto;
    border: 1px dashed var(--border-default, #d1d5db);
    background: transparent;
    color: var(--text-muted, #9ca3af);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.sidebar-reply-btn:hover {
    border-color: var(--brand-primary, #2563eb);
    color: var(--brand-primary, #2563eb);
    background: var(--brand-primary-subtle, #dbeafe);
}

/* ════════════════════════════════════════════════════════════════
   KANBAN COLUMN HEADERS — Light/Dark Mode Design System
   ════════════════════════════════════════════════════════════════ */

/* ── Light Mode (Default) ── */
.kanban-column-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    padding-right: 36px;
    border-radius: 12px 12px 0 0;
    color: #0F172A;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.kanban-column-title-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
}

.kanban-stage-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

.kanban-stage-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.kanban-stage-name {
    font-size: 16px;
    font-weight: 600;
    color: white;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.kanban-stage-range {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.3;
    white-space: nowrap;
    flex-shrink: 0;
}

.kanban-settings-btn {
    position: absolute;
    top: 10px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #64748B;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
    z-index: 1;
}

.kanban-settings-btn:hover {
    background: transparent;
    border-color: #CBD5E1;
    color: #334155;
    transform: none;
}

.kanban-column-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kanban-metric {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}

.kanban-metric-label {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.kanban-metric-value {
    font-size: 16px;
    font-weight: 700;
    color: #020617;
    line-height: 1.4;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kanban-column-header-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.kanban-sort-label {
    font-size: 12px;
    color: #64748B;
    font-weight: 500;
}

.kanban-sort-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.kanban-sort-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

/* ── Settings Popover ── */
.kanban-settings-popover {
    position: fixed;
    z-index: 1200;
    min-width: 180px;
    max-width: 260px;
    padding: 8px 0;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.kanban-settings-popover-title {
    font-size: 13px;
    font-weight: 600;
    color: #94A3B8;
    padding: 6px 16px 8px;
    border-bottom: 1px solid #F1F5F9;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kanban-settings-popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #1E293B;
    transition: background 0.15s;
    user-select: none;
}

.kanban-settings-popover-item:hover {
    background: #F8FAFC;
}

.kanban-settings-popover-item:active {
    background: #F1F5F9;
}

.kspi-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    flex-shrink: 0;
}

.kspi-label {
    flex: 1;
    min-width: 0;
}

/* ── Dark Mode disabled (app forced light) ──
@media (prefers-color-scheme: dark) {
    .kanban-column-header {
        color: #F1F5F9;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }

    .kanban-settings-btn {
        background: transparent;
        border-color: transparent;
        color: #94A3B8;
    }

    .kanban-settings-btn:hover {
        background: transparent;
        border-color: #64748B;
        color: #F1F5F9;
    }

    .kanban-metric-label {
        color: #94A3B8;
    }

    .kanban-metric-value {
        color: #FFFFFF;
    }

    .kanban-column-header-footer {
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .kanban-sort-label {
        color: #94A3B8;
    }

    .kanban-sort-btn {
        background: rgba(255, 255, 255, 0.1);
        color: #F1F5F9;
    }

    .kanban-sort-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }
}
*/

/* ── Stage Color Variants (Light Mode) ── */
.kanban-column-header[data-stage-color="orange"] {
    background: #FFF7ED;
    border: 1px solid #FED7AA;
}

.kanban-column-header[data-stage-color="blue"] {
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
}

.kanban-column-header[data-stage-color="purple"] {
    background: #FAF5FF;
    border: 1px solid #E9D5FE;
}

.kanban-column-header[data-stage-color="green"] {
    background: #F0FDF4;
    border: 1px solid #BBF7D0;
}

.kanban-column-header[data-stage-color="red"] {
    background: #FEF2F2;
    border: 1px solid #FECACA;
}

/* ── Stage Badge Colors (Light Mode) ── */
.kanban-stage-badge[data-stage-color="orange"] {
    background: #F97316;
}

.kanban-stage-badge[data-stage-color="blue"] {
    background: #2563EB;
}

.kanban-stage-badge[data-stage-color="purple"] {
    background: #A855F7;
}

.kanban-stage-badge[data-stage-color="green"] {
    background: #10B981;
}

.kanban-stage-badge[data-stage-color="red"] {
    background: #EF4444;
}

/* ── Stage Color Variants (Dark Mode) disabled (app forced light) ──
@media (prefers-color-scheme: dark) {
    .kanban-column-header[data-stage-color="orange"] {
        background: rgba(249, 115, 22, 0.1);
        border: 1px solid rgba(249, 115, 22, 0.3);
    }

    .kanban-column-header[data-stage-color="blue"] {
        background: rgba(37, 99, 235, 0.1);
        border: 1px solid rgba(37, 99, 235, 0.3);
    }

    .kanban-column-header[data-stage-color="purple"] {
        background: rgba(168, 85, 247, 0.1);
        border: 1px solid rgba(168, 85, 247, 0.3);
    }

    .kanban-column-header[data-stage-color="green"] {
        background: rgba(16, 185, 129, 0.1);
        border: 1px solid rgba(16, 185, 129, 0.3);
    }

    .kanban-column-header[data-stage-color="red"] {
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid rgba(239, 68, 68, 0.3);
    }

    .kanban-stage-badge[data-stage-color="orange"] {
        background: #F97316;
    }

    .kanban-stage-badge[data-stage-color="blue"] {
        background: #2563EB;
    }

    .kanban-stage-badge[data-stage-color="purple"] {
        background: #A855F7;
    }

    .kanban-stage-badge[data-stage-color="green"] {
        background: #10B981;
    }

    .kanban-stage-badge[data-stage-color="red"] {
        background: #EF4444;
    }
}
*/

/* Legacy kanban column styles (for backward compatibility) */
.kanban-column-title {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.kanban-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.kanban-column-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 8px;
}

.kanban-probability {
    font-weight: 500;
}

.kanban-column-total {
    font-weight: 600;
    color: white;
}

.kanban-column-forecast {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 6px;
    font-weight: 500;
}

.amount-compact {
    font-size: 11px;
    opacity: 0.8;
    margin-left: 2px;
}

/* ── Kanban Board Container ── */
#kanbanBoard {
    display: flex;
    gap: 16px;
    padding: 16px;
    overflow-x: auto;
    align-items: flex-start;
}

.kanban-column {
    display: flex;
    flex-direction: column;
    min-width: 320px;
    width: 320px;
    flex-shrink: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    min-height: 200px;
}

@media (max-width: 1200px) {
    .deal-form-body.is-premium-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .deal-form-right-sidebar {
        overflow-y: visible;
        max-height: none;
    }

    .deal-form .commission-eligibility-check {
        padding-left: 0;
    }
}

@media (max-width: 768px) {
    #dealModal.modal.active {
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
        overflow: hidden;
    }

    #dealModal .modal-content.modal-deal {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #dealModal .deal-form {
        min-height: 0;
        flex: 1;
    }

    #dealModal .deal-form-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content.modal-deal,
    .premium-enabled .modal-content.modal-deal {
        width: 100%;
        max-width: 100%;
        max-height: 100dvh;
        height: auto;
        min-height: 0;
        margin: 0;
        border-radius: 0;
    }

    .deal-form-body.is-premium-layout {
        padding: var(--space-2);
    }

    .deal-form-stepper {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .deal-stepper-step {
        flex: 0 0 auto;
        min-width: max-content;
    }

    .deal-stepper-connector {
        display: none;
    }

    .deal-form-inline-pair {
        grid-template-columns: 1fr;
    }

    .premium-card {
        padding: 16px;
    }

    .premium-commission-header {
        flex-direction: column;
    }

    .premium-contact-header,
    .premium-contact-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .deal-next-step-bar.is-premium {
        flex-direction: column;
    }

    .deal-form-header {
        flex-wrap: wrap;
        padding: var(--space-2);
    }

    .deal-form-title {
        white-space: normal;
        font-size: var(--font-size-lg, 1.125rem);
    }

    .deal-form-footer-row {
        flex-wrap: wrap;
        gap: var(--space-2);
    }

    .deal-form-footer-row .deal-form-actions {
        margin-left: 0;
        width: 100%;
        justify-content: stretch;
    }

    .deal-form-meta {
        width: 100%;
        order: 3;
    }
}

@media (max-width: 640px) {
    .deal-form .deal-form-grid-1 .form-group {
        grid-template-columns: 1fr;
        row-gap: 6px;
        align-items: stretch;
    }

    .deal-form .deal-form-grid-1 .form-group > label {
        grid-column: 1;
    }

    .deal-form .deal-form-grid-1 .form-group .form-input,
    .deal-form .deal-form-grid-1 .form-group select,
    .deal-form .deal-form-grid-1 .form-group textarea,
    .deal-form .deal-form-grid-1 .form-group .input-adorned,
    .deal-form .deal-form-grid-1 .form-group .select-with-icon,
    .deal-form .deal-form-grid-1 .form-group .form-input-wrap,
    .deal-form .deal-form-grid-1 .form-group .probability-control {
        grid-column: 1;
    }

    .deal-form .deal-form-grid-1 .form-group .field-error,
    .deal-form .deal-form-grid-1 .form-group .field-warning,
    .deal-form .deal-form-grid-1 .form-group .field-hint {
        grid-column: 1;
    }

    .deal-form .deal-form-inline-pair .form-group {
        grid-template-columns: 1fr;
    }

    .probability-control-row {
        flex-wrap: wrap;
    }
}

/* ── Activity Centered Modal ── */
.activity-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.activity-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 420px;
    max-width: 94vw;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
}
.activity-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 0;
}
.activity-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}
.activity-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 0 4px;
}
.activity-modal-close:hover { color: #111; }
.activity-modal-body {
    padding: 16px 20px 20px;
}
.activity-modal-body .field-group {
    margin-bottom: 14px;
}
.activity-modal-body .field-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #374151;
}
.activity-modal-body .field-group input,
.activity-modal-body .field-group select,
.activity-modal-body .field-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
}
.activity-modal-body .field-group textarea {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    resize: none;
    min-height: 36px;
    line-height: 1.5;
}
.activity-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #f3f4f6;
}
.activity-modal-footer .btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #d1d5db;
    background: #fff;
    font-family: inherit;
    line-height: 1.4;
}
.activity-modal-footer .btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.activity-modal-footer .btn-primary:hover { background: #1d4ed8; }

/* ── Activity List in Sidebar ── */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.activity-list-item {
    background: var(--surface-background, #f8fafc);
    border: 1px solid var(--border-default, #e2e8f0);
    border-radius: 10px;
    padding: 10px 10px 9px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.activity-list-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}
.activity-list-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 6px;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    display: block;
}
.activity-menu-btn {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    position: relative;
}
.activity-menu-btn:hover {
    color: var(--text-primary, #111827);
    border-color: var(--border-subtle, #e5e7eb);
    background: var(--surface-hover, #f3f4f6);
}
.activity-menu-btn.active {
    color: var(--text-primary, #111827);
    border-color: var(--border-default, #d1d5db);
    background: var(--surface-hover, #e5e7eb);
}
.activity-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 100;
    min-width: 120px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-top: 2px;
}
.activity-menu-dropdown.open {
    display: block;
}
.activity-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.activity-menu-dropdown button:hover {
    background: #f3f4f6;
}
.activity-menu-dropdown button.is-delete-option {
    color: #dc2626;
}
.activity-menu-dropdown button.is-delete-option:hover {
    background: #fef2f2;
}
.activity-list-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
}

.activity-list-item-meta-compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
}

.activity-assignee-wrap,
.activity-due-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.activity-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--brand-primary, #2563eb);
    background: color-mix(in srgb, var(--brand-primary, #2563eb) 18%, white);
    border: 1px solid color-mix(in srgb, var(--brand-primary, #2563eb) 38%, white);
    flex-shrink: 0;
}

.activity-due-wrap .activity-meta-label {
    color: var(--text-muted, #94a3b8);
}

.activity-list-item-meta-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
}

.activity-meta-field {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.activity-meta-label {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
}

.activity-meta-value {
    font-size: 11px;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-meta-field-status {
    justify-self: end;
}

.activity-status-select {
    min-width: 98px;
    height: 24px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: 11px;
    font-weight: 600;
    padding: 0 10px;
    font-family: inherit;
}

.activity-status-select.is-pending {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.activity-status-select.is-done {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.activity-status-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}
.activity-list-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    justify-content: flex-end;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.activity-status-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.activity-status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}
.activity-status-badge.done {
    background: #d1fae5;
    color: #065f46;
}
.activity-action-btn {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    color: #374151;
}
.activity-action-btn:hover { background: #f3f4f6; }
.activity-action-btn.is-done {
    background: #059669;
    color: #fff;
    border-color: #059669;
}
.activity-action-btn.is-done:hover { background: #047857; }
.activity-action-btn.is-pending {
    background: #d97706;
    color: #fff;
    border-color: #d97706;
}
.activity-action-btn.is-pending:hover { background: #b45309; }
.activity-action-btn.is-edit {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.activity-action-btn.is-edit:hover { background: #1d4ed8; }
.activity-load-more {
    display: block;
    text-align: center;
    font-size: 12px;
    color: #2563eb;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
    margin-top: 4px;
    font-family: inherit;
}
.activity-load-more:hover { text-decoration: underline; }
.activity-empty {
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
    padding: 12px 0;
}

/* ── Activity Drawer ── */
.activity-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 10020;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    transition: opacity 0.16s ease;
    pointer-events: none;
}

.activity-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.activity-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: min(980px, 96vw);
    height: 100vh;
    background: var(--surface-elevated, #ffffff);
    border-left: 1px solid var(--border-subtle, #e5e7eb);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.16s ease;
}

.activity-drawer-overlay.active .activity-drawer {
    transform: translateX(0);
}

.activity-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
}

.activity-drawer-eyebrow {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted, #9ca3af);
}

.activity-drawer-header h2 {
    margin: 2px 0 0;
    font-size: 22px;
    line-height: 1.2;
}

.activity-drawer-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle, #e5e7eb);
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
}

.activity-drawer-controls {
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    display: grid;
    gap: 10px;
}

.activity-drawer-pills {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.activity-drawer-pill-divider {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: var(--border-subtle, #e5e7eb);
    margin: 0 2px;
    flex-shrink: 0;
}

.activity-drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 20px;
}

.activity-drawer-feed {
    display: grid;
    gap: 10px;
}

.activity-drawer-group {
    display: grid;
    gap: 8px;
}

.activity-drawer-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #9ca3af);
    background: var(--surface-elevated, #ffffff);
    padding: 4px 0;
}

.activity-drawer-group-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0;
}

.activity-drawer-end {
    margin: 8px 0 2px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted, #9ca3af);
}

.activity-drawer-footer {
    border-top: 1px solid var(--border-subtle, #e5e7eb);
    padding: 12px 20px 14px;
    background: var(--surface-elevated, #ffffff);
}

.activity-drawer-footer .sidebar-comment-input {
    margin-top: 0;
}

.activity-drawer-footer-meta {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    display: flex;
    justify-content: space-between;
}

body.activity-drawer-open {
    overflow: hidden;
}

.crm-activity-item {
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    padding: 8px 0;
}

.crm-comment-item {
    /* `.crm-activity-item` already applies the vertical padding; avoid doubling it */
    padding: 0;
}

.crm-activity-line1 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crm-activity-line2 {
    margin-top: 2px;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-secondary, #6b7280);
    line-height: 1.35;
}

.activity-drawer .crm-comment-item .crm-activity-line2 {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.5;
}

.activity-drawer .crm-comment-item .crm-activity-body {
    display: block;
}

.crm-activity-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex: 0 0 8px;
    margin-top: 1px;
    background: #9ca3af;
}

.crm-activity-type-dot.is-nextstep {
    background: #d97706;
}

.crm-activity-type-dot.is-task {
    background: #2563eb;
}

.crm-activity-type-dot.is-edit {
    background: #64748b;
}

.crm-activity-type-dot.is-stage {
    background: #3b82f6;
}

.crm-activity-type-dot.is-created {
    background: #16a34a;
}

.crm-activity-type-dot.is-comment {
    background: #8b5cf6;
}

.crm-activity-subject {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    line-height: 1.25;
}

.crm-activity-time {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

.crm-action-item .crm-activity-actions,
.crm-system-event .crm-activity-actions,
.crm-comment-item .crm-activity-actions {
    margin-top: 3px;
    padding-left: 18px;
}

@media (max-width: 640px) {
    .activity-list-item-meta-compact {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .activity-meta-field-status {
        justify-self: start;
    }

    .activity-list-item-meta-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .activity-meta-field-status {
        justify-self: start;
    }
}

/* ── Auto-resize textarea ── */
.auto-resize-textarea {
    width: 100%;
    min-height: 24px;
    max-height: 120px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    box-sizing: border-box;
    overflow-y: hidden;
    transition: height 0.1s ease;
}
.auto-resize-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

/* ── Toggle Switch ── */
.toggle-row {
    display: grid !important;
    grid-template-columns: var(--deal-field-label-width, 140px) 1fr;
    column-gap: 10px;
    align-items: center;
    padding: 8px 0;
}

.toggle-label-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
}

.toggle-label-group label {
    font-size: var(--font-caption, 0.8rem);
    font-weight: var(--font-weight-medium, 500);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--border-default, #d1d5db);
    border-radius: 10px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--brand-primary, #2563eb);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(16px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* ===== Custom Date Field (Deal Date) ===== */

.custom-date-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.custom-date-field .form-input {
    width: 100%;
    padding-right: 40px;
}

.date-trigger {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md, 6px);
    background: transparent;
    color: var(--text-secondary, #6B7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    z-index: 100;
}

.date-trigger:hover {
    background: var(--surface-hover, #F3F4F6);
    color: var(--text-primary, #111827);
}

.date-trigger:active {
    background: var(--border-default, #E5E7EB);
}

.date-trigger:focus-visible {
    outline: 2px solid var(--brand-primary, #2563eb);
    outline-offset: -2px;
}

/* Popup calendar */

.date-popup {
    position: fixed;
    z-index: 99999;
    min-width: 260px;
    padding: 12px;
    background-color: var(--surface-elevated, #ffffff);
    opacity: 1;
    border: 1px solid var(--border-default, #E5E7EB);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    user-select: none;
}

.date-popup.drop-down {
    top: calc(100% + 4px);
    left: 0;
}

.date-popup.drop-up {
    /* Vertical position is set inline by DealDateField. Do NOT set `bottom` here —
       combining it with the inline `top` collapses the box height to 0, hiding the
       solid background and making the calendar look transparent. */
    left: 0;
}

.date-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.date-popup-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #111827);
}

.date-popup-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md, 6px);
    background: transparent;
    color: var(--text-secondary, #6B7280);
    cursor: pointer;
    transition: background 0.15s;
}

.date-popup-nav:hover {
    background: var(--surface-hover, #F3F4F6);
    color: var(--text-primary, #111827);
}

.date-popup-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.date-popup-weekdays span {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #6B7280);
    text-transform: uppercase;
}

.date-popup-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.date-popup-day-empty {
    display: block;
}

.date-popup-day {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md, 6px);
    background: transparent;
    color: var(--text-primary, #111827);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s;
}

.date-popup-day:hover {
    background: var(--surface-hover, #F3F4F6);
}

.date-popup-day-today {
    font-weight: 700;
    color: var(--brand-primary, #2563eb);
}

.date-popup-day-selected {
    background: var(--brand-primary, #2563eb);
    color: #fff;
    font-weight: 600;
}

.date-popup-day-selected:hover {
    background: var(--brand-primary-hover, #1d4ed8);
}

.date-popup-day-disabled {
    color: var(--text-disabled, #d1d5db) !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.date-popup-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
