:root {
    --brand: #660000;
    --brand-dark: #4d0000;
    --brand-highlight: #7a1a1a;
    --sidebar: #1f1a1a;
    --sidebar-soft: #332424;
    --sidebar-text: #fff7f5;
    --sidebar-muted: #e7cfcf;
    --page: #f7f5f4;
    --card: #ffffff;
    --line: #e5dfdc;
    --success: #2e7d32;
    --warning: #d97706;
    --danger: #dc2626;
    --neutral: #838383;
    --text: #2f2a2a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: "Instrument Sans", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(102, 0, 0, 0.12), transparent 26%),
        linear-gradient(180deg, #efe8e8 0%, #faf8f7 18%, #f7f5f4 100%);
}

body.menu-open {
    overflow: hidden;
}

.mobile-drawer {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.mobile-drawer.open {
    transform: translateX(0);
}

.mobile-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.mobile-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 0.9rem;
    color: var(--sidebar-text);
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(255, 235, 235, 0.16), rgba(255, 255, 255, 0.06));
    border-color: rgba(255, 240, 240, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 245, 245, 0.06), 0 12px 24px rgba(30, 0, 0, 0.22);
    color: #fff;
}

.sidebar-panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 240, 240, 0.05));
    border: 1px solid rgba(255, 240, 240, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 248, 248, 0.05);
}

.sidebar-kicker {
    color: var(--sidebar-muted);
}

.sidebar-subtext {
    color: rgba(255, 231, 231, 0.78);
}

.card-surface {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(229, 223, 220, 0.95);
    border-radius: 1.5rem;
    box-shadow: 0 16px 40px rgba(58, 32, 32, 0.07);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -2rem -2rem auto;
    width: 8rem;
    height: 8rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(102, 0, 0, 0.16), transparent 70%);
}

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-contacted { background: #f0f0f0; color: #5f5f5f; }
.status-approved { background: #e7f4e8; color: #256628; }
.status-enrolled { background: #e7f4e8; color: #2e7d32; }
.status-rejected { background: #fdeaea; color: #9b2c2c; }
.status-awarded { background: #f7ebeb; color: #660000; }
.status-redeemed { background: #f3f3f3; color: #5f5f5f; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }

.table-input {
    width: 100%;
    border: 1px solid #d7d0cb;
    border-radius: 0.75rem;
    padding: 0.55rem 0.8rem;
    background: #fff;
}

.form-shell {
    max-width: 100%;
    overflow-x: hidden;
}

#referral-form {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

#referral-form .form-field,
#referral-form .form-actions,
#referral-form #duplicate-save-banner,
#referral-form #duplicate-hint {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

#referral-form input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
#referral-form select,
#referral-form textarea,
#referral-form button,
#referral-form a.btn-secondary {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.form-grid {
    display: grid;
    gap: 1.25rem;
    width: 100%;
    min-width: 0;
}

.form-field {
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.form-actions > * {
    max-width: 100%;
}

.form-control-block {
    display: block;
    width: 100%;
    max-width: 100%;
}

.form-shell input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
.form-shell select,
.form-shell textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 3rem;
    border: 1px solid #d7d0cb;
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    background: #fff;
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.35;
    appearance: none;
}

.form-shell textarea {
    min-height: 7rem;
    resize: vertical;
}

.form-shell input:focus,
.form-shell select:focus,
.form-shell textarea:focus {
    outline: none;
    border-color: rgba(102, 0, 0, 0.45);
    box-shadow: 0 0 0 4px rgba(102, 0, 0, 0.08);
}

.form-shell input[disabled],
.form-shell select[disabled],
.form-shell textarea[disabled] {
    background: #f3f3f3;
    color: #5f5f5f;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.9rem;
    padding: 0.75rem 1.1rem;
    font-weight: 700;
    transition: all 0.2s ease;
    max-width: 100%;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #ece8e6; color: #2f2a2a; }
.btn-secondary:hover { background: #ddd6d2; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.btn-disabled,
.btn-disabled:hover {
    background: var(--neutral) !important;
    color: #fff !important;
    border: 1px solid #d4d4d4;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
    cursor: not-allowed;
    opacity: 0.75;
    pointer-events: none;
}

.animate-rise {
    animation: rise 0.4s ease both;
}

@media (max-width: 767px) {
    .card-surface {
        border-radius: 1.25rem;
    }

    .form-grid {
        gap: 1rem;
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        width: 100%;
    }

    .form-actions > p {
        width: 100%;
    }

    #referral-form {
        grid-template-columns: minmax(0, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #referral-form .md\:col-span-2 {
        grid-column: auto !important;
    }

    #referral-form .form-field,
    #referral-form .form-actions,
    #referral-form #duplicate-save-banner {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden;
    }

    #referral-form label {
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    #referral-form input:not([type='hidden']),
    #referral-form select,
    #referral-form textarea,
    #referral-form button,
    #referral-form a.btn-secondary {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        white-space: normal;
    }

    #referral-form .form-actions {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #referral-form .form-actions > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
}

@media (min-width: 640px) {
    .form-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
