.grants-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1180px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.header-title-area h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.dashboard-header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.dashboard-header-cta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.queue-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(13, 58, 92, 0.08);
    color: var(--brand-navy);
    font-size: 0.8rem;
    font-weight: 700;
}

.pro-filter-bar {
    display: flex;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    padding: 4px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.filter-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.filter-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: rgba(13, 58, 92, 0.08);
    color: var(--brand-navy);
}

.results-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

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

.results-helper-copy {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.grants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.grant-card {
    display: flex;
    flex-direction: column;
    min-height: 280px;
    padding: 22px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    position: relative;
}

.grant-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-teal);
}

.grant-card.pending,
.grant-card.rejected {
    border-style: dashed;
    background: #fafafa;
}

.grant-card.pending {
    border-color: #cbd5e1;
}

.grant-card.rejected {
    border-color: #fca5a5;
    background: #fff7f7;
}

.card-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag,
.status-chip,
.suggestion-chip {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 999px;
    letter-spacing: 0.05em;
}

.tag.eu {
    background: #e0f2fe;
    color: #0369a1;
}

.tag.national {
    background: #fef08a;
    color: #854d0e;
}

.tag.global {
    background: #dcfce7;
    color: #166534;
}

.tag.private,
.tag.other {
    background: #ede9fe;
    color: #6d28d9;
}

.status-chip.open {
    background: #dcfce7;
    color: #166534;
}

.status-chip.upcoming {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-chip.closed {
    background: #f3f4f6;
    color: #6b7280;
}

.suggestion-chip.pending {
    background: #f3f4f6;
    color: #475569;
}

.suggestion-chip.rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.grant-card h3 {
    font-size: 1.08rem;
    margin-bottom: 12px;
    color: var(--brand-navy);
    line-height: 1.35;
    font-weight: 700;
}

.amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-teal);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.programme-line {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
    font-weight: 600;
}

.desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    flex-grow: 1;
    margin-bottom: 18px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: 1px solid var(--border-light);
    padding-top: 14px;
}

.card-footer span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 40px 28px;
    border: 1px dashed var(--border-input);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    text-align: center;
    color: var(--text-secondary);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.72);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.grant-modal,
.grant-editor-dialog {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.26);
    overflow: hidden;
    animation: modalIn 0.22s ease-out;
}

.grant-editor-dialog {
    max-width: 920px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header,
.grant-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-surface-hover);
}

.modal-header-actions,
.grant-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--text-tertiary);
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-body,
.grant-editor-body {
    padding: 28px;
    overflow-y: auto;
}

.modal-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.modal-title-row h2 {
    font-size: 1.55rem;
    color: var(--brand-navy);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill.pending {
    background: #f3f4f6;
    color: #475569;
}

.status-pill.rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.status-pill.open {
    background: #dcfce7;
    color: #166534;
}

.status-pill.upcoming {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-pill.closed {
    background: #f3f4f6;
    color: #6b7280;
}

.modal-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.meta-box {
    background: var(--bg-app);
    border: 1px solid var(--border-light);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.meta-box.highlight {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.meta-box.urgency {
    background: #fef2f2;
    border-color: #fecaca;
}

.meta-box.subtle {
    background: #f8fafc;
}

.meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.modal-section h3,
.comments-section h3,
.consortium-builder h3 {
    font-size: 1.06rem;
    margin-bottom: 10px;
}

.rich-text {
    color: var(--text-secondary);
    line-height: 1.65;
    white-space: pre-wrap;
}

.req-list {
    padding-left: 20px;
    color: var(--text-secondary);
    display: grid;
    gap: 8px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 30px 0;
}

.consortium-header,
.comments-header-row,
.comment-composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.avatar-cluster {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.org-avatar-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    background: var(--bg-app);
    border: 1px solid var(--border-light);
    font-size: 0.82rem;
    color: var(--text-primary);
}

.org-avatar-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-teal-light);
    color: var(--brand-navy);
    font-size: 0.75rem;
    font-weight: 700;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}

.grant-comment-card {
    background: var(--bg-app);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.grant-comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.grant-comment-meta {
    font-size: 0.78rem;
    color: var(--text-tertiary);
}

.grant-comment-text {
    font-size: 0.93rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
}

.file-list,
.inline-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.file-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 999px;
    background: var(--bg-app);
    border: 1px solid var(--border-light);
    font-size: 0.84rem;
    color: var(--text-primary);
}

.file-pill button {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.file-pill button:hover {
    color: #b91c1c;
}

.grant-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.grant-editor-modal.hidden {
    display: none;
}

.grant-editor-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
}

.grant-editor-dialog {
    position: relative;
    z-index: 1;
}

.grant-editor-form {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.grant-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grant-form-grid.three {
    grid-template-columns: 1.25fr 0.9fr 1fr;
}

.grant-form-input,
.grant-form-input[type="text"],
.grant-form-input[type="url"],
.grant-form-input[type="number"],
.grant-form-input[type="date"],
.grant-form-input select,
textarea.grant-form-input {
    width: 100%;
    padding: 11px 12px;
    font-size: 0.93rem;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea.grant-form-input {
    min-height: 110px;
    resize: vertical;
    line-height: 1.55;
}

.grant-form-input:focus {
    outline: none;
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 3px var(--brand-teal-light);
}

.grant-editor-form.ai-prefilling .grant-form-input,
.grant-editor-form.ai-prefilling .grant-link-row,
.grant-editor-form.ai-prefilling .dropzone {
    border: 1px solid transparent;
    background:
        linear-gradient(var(--bg-surface), var(--bg-surface)) padding-box,
        linear-gradient(90deg, var(--brand-navy), var(--brand-teal), #6ccad8, var(--brand-navy)) border-box;
    background-size: 100% 100%, 240% 100%;
    animation: grantGlowShift 1.2s linear infinite;
    box-shadow: 0 0 0 2px rgba(0, 145, 170, 0.05), 0 0 18px rgba(0, 145, 170, 0.15);
}

@keyframes grantGlowShift {
    0% {
        background-position: 0 0, 200% 0;
    }

    100% {
        background-position: 0 0, -200% 0;
    }
}

.dropzone {
    border: 1px dashed var(--border-input);
    border-radius: var(--radius-md);
    padding: 18px;
    background: #fbfdff;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.dropzone.dragover {
    border-color: var(--brand-teal);
    background: rgba(0, 145, 170, 0.06);
    transform: translateY(-1px);
}

.dropzone-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.dropzone-copy {
    display: grid;
    gap: 5px;
}

.dropzone-title {
    font-weight: 700;
    color: var(--brand-navy);
}

.dropzone-subtitle {
    font-size: 0.86rem;
    color: var(--text-secondary);
}

.dropzone-file-pill {
    margin-top: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(0, 145, 170, 0.08);
    color: var(--brand-navy);
    font-size: 0.84rem;
    font-weight: 600;
}

.form-inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.prefill-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--brand-navy);
    font-weight: 600;
}

.prefill-status-bar {
    width: 42px;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-teal), #6ccad8, var(--brand-navy));
    background-size: 220% 100%;
    animation: grantGlowShift 1.2s linear infinite;
}

.tooltip-wrap {
    position: relative;
    display: inline-flex;
}

.tooltip-wrap:hover .tooltip-bubble,
.tooltip-wrap:focus-within .tooltip-bubble {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tooltip-bubble {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 320px;
    padding: 12px 14px;
    background: var(--brand-navy);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    line-height: 1.45;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.tooltip-bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 18px;
    border: 6px solid transparent;
    border-top-color: var(--brand-navy);
}

.grant-link-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grant-link-row {
    display: grid;
    grid-template-columns: 0.9fr 1.4fr auto;
    gap: 10px;
    align-items: center;
}

.grant-editor-actions,
.modal-manage-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.warning-note,
.embed-note {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    border: 1px solid var(--border-light);
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.warning-note strong,
.embed-note strong {
    color: var(--brand-navy);
}

.danger-text {
    color: #b91c1c;
}

.editor-section-title {
    font-size: 1rem;
    color: var(--brand-navy);
    margin-bottom: 10px;
}

.editor-subtle {
    font-size: 0.84rem;
    color: var(--text-secondary);
}

@media (max-width: 900px) {
    .grants-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-header-actions {
        width: 100%;
        align-items: stretch;
    }

    .dashboard-header-cta {
        justify-content: space-between;
        width: 100%;
    }

    .grant-form-grid,
    .grant-form-grid.three,
    .modal-grid-two,
    .grant-link-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 20px;
    }

    .modal-body,
    .grant-editor-body,
    .modal-header,
    .grant-editor-header {
        padding: 20px;
    }

    .comment-composer-actions,
    .consortium-header,
    .dashboard-header-cta {
        flex-direction: column;
        align-items: stretch;
    }
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-actions .btn {
    text-decoration: none;
}

.warning-note.hidden,
#consortium-divider.hidden,
#comments-divider.hidden,
#consortium-builder.hidden,
#comments-section.hidden {
    display: none;
}

.file-list .help-text,
.inline-file-list .help-text {
    margin-top: 6px;
}

.org-avatar-pill {
    max-width: 100%;
}

.org-avatar-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.programme-bubble {
    display: inline-block;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    line-height: 1.4;
    word-wrap: break-word;
    white-space: normal;
    background-color: var(--brand-teal-light);
    color: var(--brand-navy);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
    max-width: 100%;
}

.grant-link-btn {
    margin-top: 16px;
    display: inline-flex;
}

.grant-detail-cell .grant-link-btn {
    margin-top: 12px;
}

.card-tags .tag:nth-child(2),
.modal-tags .tag:nth-child(2) {
    border-radius: var(--radius-md);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.4;
    padding: 6px 10px;
    text-transform: none;
    font-size: 0.75rem;
}