/* ── Narrow form constraint (bank account add/edit) ─────────────────────── */

.crm-form--half { max-width: 50%; }

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

.crm-form--half .field__label {
    display: block;
    margin-bottom: 0.4rem;
}

.crm-form--half .field__help {
    margin-top: 0.3rem;
    font-size: 0.875rem;
}

/* ── Engagement edit form: decline panel hidden until status = rejected ───── */

.crm-decline-panel--hidden { display: none; }

/* ── Grant Application: lifecycle stage badges ───────────────────────────── */

.crm-record-badge--lifecycle-connect    { background: #dbeafe; color: #1d4ed8; }
.crm-record-badge--lifecycle-understand { background: #e0e7ff; color: #4338ca; }
.crm-record-badge--lifecycle-commit     { background: #fce7f3; color: #be185d; }
.crm-record-badge--lifecycle-agreement  { background: #d1fae5; color: #065f46; }
.crm-record-badge--lifecycle-partner    { background: #dcfce7; color: #166534; }

/* ── Grant Application: funding status badges ───────────────────────────── */

.crm-record-badge--funding-active    { background: #fef9c3; color: #854d0e; }
.crm-record-badge--funding-awarded   { background: #dcfce7; color: #166534; }
.crm-record-badge--funding-rejected  { background: #fee2e2; color: #991b1b; }
.crm-record-badge--funding-withdrawn { background: #f3f4f6; color: #6b7280; }

/* ── Grant: status badges ────────────────────────────────────────────────── */

.crm-record-badge--grant-status-active    { background: #dcfce7; color: #166534; }
.crm-record-badge--grant-status-completed { background: #e0e7ff; color: #4338ca; }
.crm-record-badge--grant-status-cancelled { background: #fee2e2; color: #991b1b; }

/* ── Review cards ────────────────────────────────────────────────────────── */

.crm-grants-review:last-child { border-bottom: none; }

/* ── Payment schedule modal ──────────────────────────────────────────────── */

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

.crm-modal-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.crm-modal-dialog__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--w-color-border-furniture, #e5e7eb);
}

.crm-modal-dialog__title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.crm-modal-dialog__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--w-color-text-label, #374151);
    border-radius: 0.25rem;
}

.crm-modal-dialog__close:hover {
    background: var(--w-color-surface-field-inactive, #f3f4f6);
}

.crm-modal-dialog__close .icon {
    width: 1.125rem;
    height: 1.125rem;
}

.crm-modal-dialog__context {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--w-color-surface-field-inactive, #f9fafb);
    border-bottom: 1px solid var(--w-color-border-furniture, #e5e7eb);
    font-size: 0.875rem;
    color: var(--w-color-text-label, #374151);
}

.crm-modal-dialog__error-banner {
    margin: 1rem 1.5rem 0;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.crm-modal-dialog__fieldset {
    border: none;
    margin: 0;
    padding: 1.25rem 1.5rem 0;
}

.crm-modal-dialog__legend {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--w-color-text-label, #374151);
    margin-bottom: 0.75rem;
    padding: 0;
}

.crm-schedule-type-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}

.crm-schedule-type-option {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--w-color-border-furniture, #e5e7eb);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.crm-schedule-type-option:hover {
    border-color: var(--w-color-border-field-hover, #9ca3af);
    background: var(--w-color-surface-field-inactive, #f9fafb);
}

.crm-schedule-type-option input[type="radio"] {
    display: none;
}

.crm-schedule-type-option:has(input:checked) {
    border-color: var(--w-color-interactive, #007d7e);
    background: #f0fafa;
}

.crm-schedule-type-option__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--w-color-text-label, #111827);
}

.crm-schedule-type-option__hint {
    font-size: 0.8125rem;
    color: var(--w-color-text-meta, #6b7280);
    line-height: 1.4;
}

.crm-modal-dialog__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0;
}

.crm-modal-dialog__field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
    min-width: 10rem;
}

.crm-modal-dialog__field--optional {
    padding: 0 1.5rem;
    margin-top: 1rem;
}

.crm-modal-dialog__field--optional label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.crm-modal-dialog__field-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--w-color-text-label, #374151);
}

.crm-modal-dialog__field-optional {
    font-weight: 400;
    color: var(--w-color-text-meta, #6b7280);
}

.crm-modal-dialog__input {
    width: 100%;
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--w-color-border-field-default, #d1d5db);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    background: #fff;
    box-sizing: border-box;
}

.crm-modal-dialog__input:focus {
    outline: 2px solid var(--w-color-interactive, #007d7e);
    outline-offset: 1px;
    border-color: transparent;
}

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

.crm-modal-dialog__actions {
    display: flex;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--w-color-border-furniture, #e5e7eb);
}

.crm-modal-dialog__loading,
.crm-modal-dialog__error {
    padding: 2rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--w-color-text-meta, #6b7280);
}

/* Standalone field (outside .crm-modal-dialog__fields grid) */
.crm-modal-dialog > form > .crm-modal-dialog__field,
.crm-modal-dialog__field--standalone {
    padding: 1.25rem 1.5rem 0;
}

.crm-modal-dialog__field-hint {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--w-color-text-meta, #6b7280);
    margin-top: 0.125rem;
}

/* ── Duplicate warning ───────────────────────────────────────────────────── */

.crm-duplicate-warning {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--w-color-border-furniture, #e5e7eb);
}

.crm-duplicate-warning__planned {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.crm-duplicate-warning__table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ── Milestone rows ──────────────────────────────────────────────────────── */

.crm-schedule-milestones {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem 0;
}

.crm-schedule-milestone-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.crm-schedule-milestone-row input {
    flex: 1;
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--w-color-border-field-default, #d1d5db);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.crm-schedule-milestones__add {
    margin: 0.75rem 1.5rem 0;
}

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

.crm-record-header__subtitle {
    font-size: var(--w-font-size-14, 0.875rem);
    color: var(--w-color-text-label);
    margin-top: 0.25rem;
}
